MediaWiki  REL1_21
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                 $this->hideDeprecated( 'CategoryPage::getAutosummary' ); // Inherited from Article
00066 
00067                 $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
00068                         "Article static functions" );
00069                 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
00070                         "Article static functions" );
00071                 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
00072                         "Article static functions" );
00073                 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
00074                         "Article static functions" );
00075                 $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
00076                         "Article static functions" );
00077         }
00078 
00079         function testWikiPageFactory() {
00080                 $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
00081                 $page = WikiPage::factory( $title );
00082                 $this->assertEquals( 'WikiFilePage', get_class( $page ) );
00083 
00084                 $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
00085                 $page = WikiPage::factory( $title );
00086                 $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
00087 
00088                 $title = Title::makeTitle( NS_MAIN, 'SomePage' );
00089                 $page = WikiPage::factory( $title );
00090                 $this->assertEquals( 'WikiPage', get_class( $page ) );
00091         }
00092 }