2011-06-29 22:09:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class ArticleTest extends MediaWikiTestCase {
|
|
|
|
|
|
2011-07-03 17:51:11 +00:00
|
|
|
private $title; // holds a Title object
|
|
|
|
|
private $article; // holds an article
|
|
|
|
|
|
|
|
|
|
/** creates a title object and its article object */
|
|
|
|
|
function setUp() {
|
2011-09-07 17:55:37 +00:00
|
|
|
$this->title = Title::makeTitle( NS_MAIN, 'SomePage' );
|
2011-07-03 17:51:11 +00:00
|
|
|
$this->article = new Article( $this->title );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** cleanup title object and its article object */
|
|
|
|
|
function tearDown() {
|
|
|
|
|
$this->title = null;
|
|
|
|
|
$this->article = null;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-11 13:29:21 +00:00
|
|
|
function testImplementsGetMagic() {
|
|
|
|
|
$this->assertEquals( false, $this->article->mLatest, "Article __get magic" );
|
2011-07-03 17:51:11 +00:00
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
|
2011-07-03 17:51:11 +00:00
|
|
|
/**
|
|
|
|
|
* @depends testImplementsGetMagic
|
|
|
|
|
*/
|
|
|
|
|
function testImplementsSetMagic() {
|
2011-12-11 13:29:21 +00:00
|
|
|
$this->article->mLatest = 2;
|
|
|
|
|
$this->assertEquals( 2, $this->article->mLatest, "Article __set magic" );
|
2011-07-03 17:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @depends testImplementsSetMagic
|
|
|
|
|
*/
|
|
|
|
|
function testImplementsCallMagic() {
|
2011-12-11 13:29:21 +00:00
|
|
|
$this->article->mLatest = 33;
|
2011-12-27 20:48:06 +00:00
|
|
|
$this->article->mDataLoaded = true;
|
2011-12-11 13:29:21 +00:00
|
|
|
$this->assertEquals( 33, $this->article->getLatest(), "Article __call magic" );
|
2011-07-03 17:51:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testGetOrSetOnNewProperty() {
|
|
|
|
|
$this->article->ext_someNewProperty = 12;
|
|
|
|
|
$this->assertEquals( 12, $this->article->ext_someNewProperty,
|
|
|
|
|
"Article get/set magic on new field" );
|
|
|
|
|
|
|
|
|
|
$this->article->ext_someNewProperty = -8;
|
|
|
|
|
$this->assertEquals( -8, $this->article->ext_someNewProperty,
|
|
|
|
|
"Article get/set magic on update to new field" );
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-23 20:23:26 +00:00
|
|
|
/**
|
|
|
|
|
* Checks for the existence of the backwards compatibility static functions (forwarders to WikiPage class)
|
|
|
|
|
*/
|
2011-07-03 17:51:11 +00:00
|
|
|
function testStaticFunctions() {
|
2011-06-29 22:09:51 +00:00
|
|
|
$this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
|
|
|
|
|
"Article static functions" );
|
2011-07-23 20:23:26 +00:00
|
|
|
$this->assertEquals( true, is_callable( "Article::onArticleCreate" ),
|
2011-06-29 22:09:51 +00:00
|
|
|
"Article static functions" );
|
2011-07-23 20:23:26 +00:00
|
|
|
$this->assertEquals( true, is_callable( "Article::onArticleDelete" ),
|
2011-06-29 22:09:51 +00:00
|
|
|
"Article static functions" );
|
2011-07-23 20:23:26 +00:00
|
|
|
$this->assertEquals( true, is_callable( "ImagePage::onArticleEdit" ),
|
2011-06-29 22:09:51 +00:00
|
|
|
"Article static functions" );
|
2011-09-07 13:04:40 +00:00
|
|
|
$this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
|
2011-06-29 22:09:51 +00:00
|
|
|
"Article static functions" );
|
|
|
|
|
}
|
2011-07-03 17:51:11 +00:00
|
|
|
|
2011-07-12 18:01:16 +00:00
|
|
|
function testWikiPageFactory() {
|
|
|
|
|
$title = Title::makeTitle( NS_FILE, 'Someimage.png' );
|
2011-07-12 20:32:09 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
2011-07-12 18:01:16 +00:00
|
|
|
$this->assertEquals( 'WikiFilePage', get_class( $page ) );
|
|
|
|
|
|
|
|
|
|
$title = Title::makeTitle( NS_CATEGORY, 'SomeCategory' );
|
2011-07-12 20:32:09 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
2011-07-12 18:01:16 +00:00
|
|
|
$this->assertEquals( 'WikiCategoryPage', get_class( $page ) );
|
|
|
|
|
|
|
|
|
|
$title = Title::makeTitle( NS_MAIN, 'SomePage' );
|
2011-07-12 20:32:09 +00:00
|
|
|
$page = WikiPage::factory( $title );
|
2011-07-12 18:01:16 +00:00
|
|
|
$this->assertEquals( 'WikiPage', get_class( $page ) );
|
|
|
|
|
}
|
2011-06-29 22:09:51 +00:00
|
|
|
}
|