MediaWiki  master
ArticleTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class ArticleTest extends MediaWikiTestCase {
00004 
00008         private $title;
00012         private $article;
00013 
00015         protected function setUp() {
00016                 parent::setUp();
00017                 $this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
00018                 $this->article = new Article( $this->title );
00019         }
00020 
00022         protected function tearDown() {
00023                 parent::tearDown();
00024                 $this->title = null;
00025                 $this->article = null;
00026         }
00027 
00028         function testImplementsGetMagic() {
00029                 $this->assertEquals( false, $this->article->mLatest, "Article __get magic" );
00030         }
00031 
00035         function testImplementsSetMagic() {
00036                 $this->article->mLatest = 2;
00037                 $this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
00038         }
00039 
00043         function testImplementsCallMagic() {
00044                 $this->article->mLatest = 33;
00045                 $this->article->mDataLoaded = true;
00046                 $this->assertEquals( 33, $this->article->getLatest(), "Article __call magic" );
00047         }
00048 
00049         function testGetOrSetOnNewProperty() {
00050                 $this->article->ext_someNewProperty = 12;
00051                 $this->assertEquals( 12, $this->article->ext_someNewProperty,
00052                         "Article get/set magic on new field" );
00053                 
00054                 $this->article->ext_someNewProperty = -8;
00055                 $this->assertEquals( -8, $this->article->ext_someNewProperty,
00056                         "Article get/set magic on update to new field" );
00057         }
00058 
00062         function testStaticFunctions() {
00063                 $this->hideDeprecated( 'Article::getAutosummary' );
00064                 $this->hideDeprecated( 'WikiPage::getAutosummary' );
00065 
00066                 $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
00067                         "Article static functions" );
00068                 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
00069                         "Article static functions" );
00070                 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
00071                         "Article static functions" );
00072                 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
00073                         "Article static functions" );
00074                 $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
00075                         "Article static functions" );
00076         }
00077 
00078         function testWikiPageFactory() {
00079                 $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
00080                 $page = WikiPage::factory( $title );
00081                 $this->assertEquals( 'WikiFilePage', get_class( $page ) );
00082                 
00083                 $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
00084                 $page = WikiPage::factory( $title );
00085                 $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
00086                 
00087                 $title = Title::makeTitle( NS_MAIN, 'SomePage' );
00088                 $page = WikiPage::factory( $title );
00089                 $this->assertEquals( 'WikiPage', get_class( $page ) );
00090         }
00091 }