Merge "inputs.less: Change focus state"
[lhc/web/wiklou.git] / tests / phpunit / includes / page / ArticleTest.php
1 <?php
2
3 class ArticleTest extends MediaWikiTestCase {
4
5 /**
6 * @var Title
7 */
8 private $title;
9 /**
10 * @var Article
11 */
12 private $article;
13
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 );
19 }
20
21 /** cleanup title object and its article object */
22 protected function tearDown() {
23 parent::tearDown();
24 $this->title = null;
25 $this->article = null;
26 }
27
28 /**
29 * @covers Article::__get
30 */
31 public function testImplementsGetMagic() {
32 $this->assertEquals( false, $this->article->mLatest, "Article __get magic" );
33 }
34
35 /**
36 * @depends testImplementsGetMagic
37 * @covers Article::__set
38 */
39 public function testImplementsSetMagic() {
40 $this->article->mLatest = 2;
41 $this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
42 }
43
44 /**
45 * @depends testImplementsSetMagic
46 * @covers Article::__call
47 */
48 public function testImplementsCallMagic() {
49 $this->article->mLatest = 33;
50 $this->article->mDataLoaded = true;
51 $this->assertEquals( 33, $this->article->getLatest(), "Article __call magic" );
52 }
53
54 /**
55 * @covers Article::__get
56 * @covers Article::__set
57 */
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" );
62
63 $this->article->ext_someNewProperty = -8;
64 $this->assertEquals( -8, $this->article->ext_someNewProperty,
65 "Article get/set magic on update to new field" );
66 }
67
68 /**
69 * Checks for the existence of the backwards compatibility static functions
70 * (forwarders to WikiPage class)
71 *
72 * @covers Article::selectFields
73 * @covers Article::onArticleCreate
74 * @covers Article::onArticleDelete
75 * @covers Article::onArticleEdit
76 * @covers Article::getAutosummary
77 */
78 public function testStaticFunctions() {
79 $this->hideDeprecated( 'Article::selectFields' );
80 $this->hideDeprecated( 'Article::getAutosummary' );
81 $this->hideDeprecated( 'WikiPage::getAutosummary' );
82 $this->hideDeprecated( 'CategoryPage::getAutosummary' ); // Inherited from Article
83
84 $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
85 "Article static functions" );
86 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
87 "Article static functions" );
88 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
89 "Article static functions" );
90 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
91 "Article static functions" );
92 $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
93 "Article static functions" );
94 }
95 }