wiki.techinc.nl/tests/phpunit/includes/page/ArticleTest.php
Petr Pchelko 890452301d Drop Article::getEmptyPageParserOutput
The only place where this was used is to show the system
message contents on a missing article page in NS_MEDIAWIKI
namespace, which is much easier done without MessageContent.

The override in ImagePage is a guaranteed no-op, cause we can't
have ImagePage for NS_MEDIAWIKI namespace.

These were the only two places where this method was used across
codesearch.

Change-Id: I9b9be61eaff6d153fbd2381c91c598b3421e5ea2
2020-11-15 08:57:24 -07:00

98 lines
2.7 KiB
PHP

<?php
/**
* @group Database
*/
class ArticleTest extends \MediaWikiIntegrationTestCase {
/**
* @var Title
*/
private $title;
/**
* @var Article
*/
private $article;
/** creates a title object and its article object */
protected function setUp() : void {
parent::setUp();
$this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
$this->article = new Article( $this->title );
}
/** cleanup title object and its article object */
protected function tearDown() : void {
parent::tearDown();
$this->title = null;
$this->article = null;
}
/**
* @covers Article::__get
*/
public function testImplementsGetMagic() {
$this->filterDeprecated( '/Accessing Article::\$mLatest/' );
$this->assertFalse( $this->article->mLatest, "Article __get magic" );
}
/**
* @depends testImplementsGetMagic
* @covers Article::__set
*/
public function testImplementsSetMagic() {
$this->filterDeprecated( '/Accessing Article::\$mLatest/' );
$this->filterDeprecated( '/Setting Article::\$mLatest/' );
$this->article->mLatest = 2;
$this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
}
/**
* @covers Article::__get
* @covers Article::__set
*/
public function testGetOrSetOnNewProperty() {
$this->filterDeprecated(
'/Accessing Article::\$ext_someNewProperty/'
);
$this->filterDeprecated(
'/Setting Article::\$ext_someNewProperty/'
);
$this->article->ext_someNewProperty = 12;
$this->assertEquals( 12, $this->article->ext_someNewProperty,
"Article get/set magic on new field" );
$this->assertEquals( 12, $this->article->getPage()->ext_someNewProperty,
"Article get/set magic on new field" );
$this->article->ext_someNewProperty = -8;
$this->assertEquals( -8, $this->article->ext_someNewProperty,
"Article get/set magic on update to new field" );
$this->assertEquals( -8, $this->article->getPage()->ext_someNewProperty,
"Article get/set magic on new field" );
}
/**
* @covers Article::__sleep
*/
public function testSerialization_fails() {
$this->expectException( LogicException::class );
serialize( $this->article );
}
/**
* Tests that missing article page shows parser contents
* of the well-known system message for NS_MEDIAWIKI pages
* @covers Article::showMissingArticle
*/
public function testMissingArticleMessage() {
// Use a well-known system message
$title = Title::makeTitle( NS_MEDIAWIKI, 'uploadedimage' );
$article = new Article( $title, 0 );
$article->getContext()->getOutput()->setTitle( $title );
$article->showMissingArticle();
$output = $article->getContext()->getOutput();
$this->assertStringContainsString(
Message::newFromKey( 'uploadedimage' )->parse(),
$output->getHTML()
);
}
}