Merge "Fixed dependencies for jquery.collapsibleTabs"
[lhc/web/wiklou.git] / tests / phpunit / includes / 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 $this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
17 $this->article = new Article( $this->title );
18
19 }
20
21 /** cleanup title object and its article object */
22 protected function tearDown() {
23 $this->title = null;
24 $this->article = null;
25
26 }
27
28 function testImplementsGetMagic() {
29 $this->assertEquals( false, $this->article->mLatest, "Article __get magic" );
30 }
31
32 /**
33 * @depends testImplementsGetMagic
34 */
35 function testImplementsSetMagic() {
36 $this->article->mLatest = 2;
37 $this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
38 }
39
40 /**
41 * @depends testImplementsSetMagic
42 */
43 function testImplementsCallMagic() {
44 $this->article->mLatest = 33;
45 $this->article->mDataLoaded = true;
46 $this->assertEquals( 33, $this->article->getLatest(), "Article __call magic" );
47 }
48
49 function testGetOrSetOnNewProperty() {
50 $this->article->ext_someNewProperty = 12;
51 $this->assertEquals( 12, $this->article->ext_someNewProperty,
52 "Article get/set magic on new field" );
53
54 $this->article->ext_someNewProperty = -8;
55 $this->assertEquals( -8, $this->article->ext_someNewProperty,
56 "Article get/set magic on update to new field" );
57 }
58
59 /**
60 * Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
61 */
62 function testStaticFunctions() {
63 $this->hideDeprecated( 'Article::getAutosummary' );
64 $this->hideDeprecated( 'WikiPage::getAutosummary' );
65
66 $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
67 "Article static functions" );
68 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
69 "Article static functions" );
70 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
71 "Article static functions" );
72 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
73 "Article static functions" );
74 $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
75 "Article static functions" );
76 }
77
78 function testWikiPageFactory() {
79 $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
80 $page = WikiPage::factory( $title );
81 $this->assertEquals( 'WikiFilePage', get_class( $page ) );
82
83 $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
84 $page = WikiPage::factory( $title );
85 $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
86
87 $title = Title::makeTitle( NS_MAIN, 'SomePage' );
88 $page = WikiPage::factory( $title );
89 $this->assertEquals( 'WikiPage', get_class( $page ) );
90 }
91 }