MediaWiki  REL1_19
ArticleTest.php
Go to the documentation of this file.
00001 <?php
00002 
00003 class ArticleTest extends MediaWikiTestCase {
00004 
00005         private $title; // holds a Title object
00006         private $article; // holds an article
00007 
00009         function setUp() {
00010                 $this->title   = Title::makeTitle( NS_MAIN, 'SomePage' );
00011                 $this->article = new Article( $this->title );
00012 
00013         }
00014 
00016         function tearDown() {
00017                 $this->title   = null;
00018                 $this->article = null;
00019 
00020         }
00021 
00022         function testImplementsGetMagic() {
00023                 $this->assertEquals( false, $this->article->mLatest, "Article __get magic" );
00024         }
00025 
00029         function testImplementsSetMagic() {
00030                 $this->article->mLatest = 2;
00031                 $this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
00032         }
00033 
00037         function testImplementsCallMagic() {
00038                 $this->article->mLatest = 33;
00039                 $this->article->mDataLoaded = true;
00040                 $this->assertEquals( 33, $this->article->getLatest(), "Article __call magic" );
00041         }
00042 
00043         function testGetOrSetOnNewProperty() {
00044                 $this->article->ext_someNewProperty = 12;
00045                 $this->assertEquals( 12, $this->article->ext_someNewProperty,
00046                         "Article get/set magic on new field" );
00047                 
00048                 $this->article->ext_someNewProperty = -8;
00049                 $this->assertEquals( -8, $this->article->ext_someNewProperty,
00050                         "Article get/set magic on update to new field" );
00051         }
00052 
00056         function testStaticFunctions() {
00057                 $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
00058                         "Article static functions" );
00059                 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
00060                         "Article static functions" );
00061                 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
00062                         "Article static functions" );
00063                 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
00064                         "Article static functions" );
00065                 $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
00066                         "Article static functions" );
00067         }
00068 
00069         function testWikiPageFactory() {
00070                 $title = Title::makeTitle( NS_FILE, 'Someimage.png' );
00071                 $page = WikiPage::factory( $title );
00072                 $this->assertEquals( 'WikiFilePage', get_class( $page ) );
00073                 
00074                 $title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
00075                 $page = WikiPage::factory( $title );
00076                 $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
00077                 
00078                 $title = Title::makeTitle( NS_MAIN, 'SomePage' );
00079                 $page = WikiPage::factory( $title );
00080                 $this->assertEquals( 'WikiPage', get_class( $page ) );
00081         }
00082 }