wiki.techinc.nl/tests/phpunit/includes/page/ArticleTest.php
ArtBaltai b32787cba2 Hard deprecate Article methods proxying to WikiPage
Hard deprecate and rewrite call of proxy methods
Deprecate Article::$mContext. It should become private

Bug: T239975
Change-Id: I92018a02b00fdc0b6cd90dfc77ad27782322f344
2020-04-24 01:02:16 +03:00

69 lines
1.9 KiB
PHP

<?php
class ArticleTest extends \MediaWikiTestCase {
/**
* @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->hideDeprecated( 'Article::__get Access to raw mLatest field' );
$this->assertFalse( $this->article->mLatest, "Article __get magic" );
}
/**
* @depends testImplementsGetMagic
* @covers Article::__set
*/
public function testImplementsSetMagic() {
$this->hideDeprecated( 'Article::__get Access to raw mLatest field' );
$this->hideDeprecated( 'Article::__set Access to raw mLatest field' );
$this->article->mLatest = 2;
$this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
}
/**
* @covers Article::__get
* @covers Article::__set
*/
public function testGetOrSetOnNewProperty() {
$this->hideDeprecated(
'Article::__get Access to raw ext_someNewProperty field'
);
$this->hideDeprecated(
'Article::__set Access to raw ext_someNewProperty field'
);
$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" );
}
}