* WikiPage functions/fields are "magically" part of Article when accessed for b/c. Magic is kind of ugly but there are too many callers to make breaking changes atm. Some functions are just wrappers for WikiPage ones (were magic won't work). * Added newFromID() to each WikiPage subclass (works around pre-existing inheritance problem). * Added Page class for convenient type hinting and changed hints from Article -> Page. This lets things use WikiPage objects without getting type errors. * Updated FlaggedPage to extend WikiPage. Worked around getOldIdFromRequest(). * Added setTimestamp() to WikiPage and moved some timestamp setting code from ParserCache to Article. * Removed ampersands from $dbw arguments. * @TODO: dependency inject user objects for WikiPage The idea is to migrate things to use WikiPage, as the run-of-the-mill "new Article()" call doesn't care about $oldid and $wgRequest. After that, Article, ImagePage, and CategoryPage can be rewritten as an Action class or something sane (a Viewer class of sorts).
34 lines
1.2 KiB
PHP
34 lines
1.2 KiB
PHP
<?php
|
|
|
|
class ArticleTest extends MediaWikiTestCase {
|
|
function testBCMagic() {
|
|
$title = Title::makeTitle( NS_MAIN, 'somePage' );
|
|
$article = new Article( $title );
|
|
|
|
$this->assertEquals( -1, $article->mCounter, "Article __get magic" );
|
|
|
|
$article->mCounter = 2;
|
|
$this->assertEquals( 2, $article->mCounter, "Article __set magic" );
|
|
|
|
$this->assertEquals( 2, $article->getCount(), "Article __call magic" );
|
|
|
|
$this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
|
|
"Article static functions" );
|
|
$this->assertEquals( null, Article::onArticleCreate( $title ),
|
|
"Article static functions" );
|
|
$this->assertEquals( null, Article::onArticleDelete( $title ),
|
|
"Article static functions" );
|
|
$this->assertEquals( null, ImagePage::onArticleEdit( $title ),
|
|
"Article static functions" );
|
|
$this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
|
|
"Article static functions" );
|
|
|
|
$article->ext_someNewProperty = 12;
|
|
$this->assertEquals( 12, $article->ext_someNewProperty,
|
|
"Article get/set magic on new field" );
|
|
|
|
$article->ext_someNewProperty = -8;
|
|
$this->assertEquals( -8, $article->ext_someNewProperty,
|
|
"Article get/set magic on update to new field" );
|
|
}
|
|
}
|