3 class ArticleTest
extends MediaWikiTestCase
{
5 private $title; // holds a Title object
6 private $article; // holds an article
8 /** creates a title object and its article object */
10 $this->title
= Title
::makeTitle( NS_MAIN
, 'SomePage' );
11 $this->article
= new Article( $this->title
);
15 /** cleanup title object and its article object */
18 $this->article
= null;
22 function testImplementsGetMagic() {
23 $this->assertEquals( false, $this->article
->mLatest
, "Article __get magic" );
27 * @depends testImplementsGetMagic
29 function testImplementsSetMagic() {
30 $this->article
->mLatest
= 2;
31 $this->assertEquals( 2, $this->article
->mLatest
, "Article __set magic" );
35 * @depends testImplementsSetMagic
37 function testImplementsCallMagic() {
38 $this->article
->mLatest
= 33;
39 $this->article
->mDataLoaded
= true;
40 $this->assertEquals( 33, $this->article
->getLatest(), "Article __call magic" );
43 function testGetOrSetOnNewProperty() {
44 $this->article
->ext_someNewProperty
= 12;
45 $this->assertEquals( 12, $this->article
->ext_someNewProperty
,
46 "Article get/set magic on new field" );
48 $this->article
->ext_someNewProperty
= -8;
49 $this->assertEquals( -8, $this->article
->ext_someNewProperty
,
50 "Article get/set magic on update to new field" );
54 * Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
56 function testStaticFunctions() {
57 $this->hideDeprecated( 'Article::getAutosummary' );
58 $this->hideDeprecated( 'WikiPage::getAutosummary' );
60 $this->assertEquals( WikiPage
::selectFields(), Article
::selectFields(),
61 "Article static functions" );
62 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
63 "Article static functions" );
64 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
65 "Article static functions" );
66 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
67 "Article static functions" );
68 $this->assertTrue( is_string( CategoryPage
::getAutosummary( '', '', 0 ) ),
69 "Article static functions" );
72 function testWikiPageFactory() {
73 $title = Title
::makeTitle( NS_FILE
, 'Someimage.png' );
74 $page = WikiPage
::factory( $title );
75 $this->assertEquals( 'WikiFilePage', get_class( $page ) );
77 $title = Title
::makeTitle( NS_CATEGORY
, 'SomeCategory' );
78 $page = WikiPage
::factory( $title );
79 $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
81 $title = Title
::makeTitle( NS_MAIN
, 'SomePage' );
82 $page = WikiPage
::factory( $title );
83 $this->assertEquals( 'WikiPage', get_class( $page ) );