3 class ArticleTest
extends MediaWikiTestCase
{
14 /** creates a title object and its article object */
15 protected function setUp() {
17 $this->title
= Title
::makeTitle( NS_MAIN
, 'SomePage' );
18 $this->article
= new Article( $this->title
);
21 /** cleanup title object and its article object */
22 protected function tearDown() {
25 $this->article
= null;
28 function testImplementsGetMagic() {
29 $this->assertEquals( false, $this->article
->mLatest
, "Article __get magic" );
33 * @depends testImplementsGetMagic
35 function testImplementsSetMagic() {
36 $this->article
->mLatest
= 2;
37 $this->assertEquals( 2, $this->article
->mLatest
, "Article __set magic" );
41 * @depends testImplementsSetMagic
43 function testImplementsCallMagic() {
44 $this->article
->mLatest
= 33;
45 $this->article
->mDataLoaded
= true;
46 $this->assertEquals( 33, $this->article
->getLatest(), "Article __call magic" );
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" );
54 $this->article
->ext_someNewProperty
= -8;
55 $this->assertEquals( -8, $this->article
->ext_someNewProperty
,
56 "Article get/set magic on update to new field" );
60 * Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
62 function testStaticFunctions() {
63 $this->hideDeprecated( 'Article::getAutosummary' );
64 $this->hideDeprecated( 'WikiPage::getAutosummary' );
65 $this->hideDeprecated( 'CategoryPage::getAutosummary' ); // Inherited from Article
67 $this->assertEquals( WikiPage
::selectFields(), Article
::selectFields(),
68 "Article static functions" );
69 $this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
70 "Article static functions" );
71 $this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
72 "Article static functions" );
73 $this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
74 "Article static functions" );
75 $this->assertTrue( is_string( CategoryPage
::getAutosummary( '', '', 0 ) ),
76 "Article static functions" );
79 function testWikiPageFactory() {
80 $title = Title
::makeTitle( NS_FILE
, 'Someimage.png' );
81 $page = WikiPage
::factory( $title );
82 $this->assertEquals( 'WikiFilePage', get_class( $page ) );
84 $title = Title
::makeTitle( NS_CATEGORY
, 'SomeCategory' );
85 $page = WikiPage
::factory( $title );
86 $this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
88 $title = Title
::makeTitle( NS_MAIN
, 'SomePage' );
89 $page = WikiPage
::factory( $title );
90 $this->assertEquals( 'WikiPage', get_class( $page ) );