Release notes for Iabf4873f
[mediawiki.git] / tests / phpunit / includes / ArticleTest.php
blob84f900fd37e02d336596e07ab444c3dc7b99547b
1 <?php
3 class ArticleTest extends MediaWikiTestCase {
5 /**
6 * @var Title
7 */
8 private $title;
9 /**
10 * @var Article
12 private $article;
14 /** creates a title object and its article object */
15 protected function setUp() {
16 parent::setUp();
17 $this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
18 $this->article = new Article( $this->title );
21 /** cleanup title object and its article object */
22 protected function tearDown() {
23 parent::tearDown();
24 $this->title = null;
25 $this->article = null;
28 /**
29 * @covers Article::__get
31 public function testImplementsGetMagic() {
32 $this->assertEquals( false, $this->article->mLatest, "Article __get magic" );
35 /**
36 * @depends testImplementsGetMagic
37 * @covers Article::__set
39 public function testImplementsSetMagic() {
40 $this->article->mLatest = 2;
41 $this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
44 /**
45 * @depends testImplementsSetMagic
46 * @covers Article::__call
48 public function testImplementsCallMagic() {
49 $this->article->mLatest = 33;
50 $this->article->mDataLoaded = true;
51 $this->assertEquals( 33, $this->article->getLatest(), "Article __call magic" );
54 /**
55 * @covers Article::__get
56 * @covers Article::__set
58 public function testGetOrSetOnNewProperty() {
59 $this->article->ext_someNewProperty = 12;
60 $this->assertEquals( 12, $this->article->ext_someNewProperty,
61 "Article get/set magic on new field" );
63 $this->article->ext_someNewProperty = -8;
64 $this->assertEquals( -8, $this->article->ext_someNewProperty,
65 "Article get/set magic on update to new field" );
68 /**
69 * Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
70 * @covers Article::selectFields
71 * @covers Article::onArticleCreate
72 * @covers Article::onArticleDelete
73 * @covers Article::onArticleEdit
74 * @covers Article::getAutosummary
76 public function testStaticFunctions() {
77 $this->hideDeprecated( 'Article::getAutosummary' );
78 $this->hideDeprecated( 'WikiPage::getAutosummary' );
79 $this->hideDeprecated( 'CategoryPage::getAutosummary' ); // Inherited from Article
81 $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
82 "Article static functions" );
83 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
84 "Article static functions" );
85 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
86 "Article static functions" );
87 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
88 "Article static functions" );
89 $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
90 "Article static functions" );