From: Antoine Musso Date: Sun, 3 Jul 2011 17:51:11 +0000 (+0000) Subject: split tests for ArticleTest X-Git-Tag: 1.31.0-rc.0~29098 X-Git-Url: http://git.cyclocoop.org/ecrire?a=commitdiff_plain;h=2fad923859ea6d502ecc2fed2f3044d6312fa3aa;p=lhc%2Fweb%2Fwiklou.git split tests for ArticleTest --- diff --git a/tests/phpunit/includes/ArticleTest.php b/tests/phpunit/includes/ArticleTest.php index 4a84692096..1814b86128 100644 --- a/tests/phpunit/includes/ArticleTest.php +++ b/tests/phpunit/includes/ArticleTest.php @@ -1,34 +1,66 @@ assertEquals( -1, $article->mCounter, "Article __get magic" ); - $article->mCounter = 2; - $this->assertEquals( 2, $article->mCounter, "Article __set magic" ); + private $title; // holds a Title object + private $article; // holds an article + + /** creates a title object and its article object */ + function setUp() { + $this->title = Title::makeTitle( NS_MAIN, 'somePage' ); + $this->article = new Article( $this->title ); + + } + + /** cleanup title object and its article object */ + function tearDown() { + $this->title = null; + $this->article = null; + + } + + function testImplementsGetMagic() { + $this->assertEquals( -1, $this->article->mCounter, "Article __get magic" ); + } - $this->assertEquals( 2, $article->getCount(), "Article __call magic" ); + /** + * @depends testImplementsGetMagic + */ + function testImplementsSetMagic() { + $this->article->mCounter = 2; + $this->assertEquals( 2, $this->article->mCounter, "Article __set magic" ); + } + + /** + * @depends testImplementsSetMagic + */ + function testImplementsCallMagic() { + $this->article->mCounter = 33; + $this->assertEquals( 33, $this->article->getCount(), "Article __call magic" ); + } + + 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" ); + } + + function testStaticFunctions() { $this->assertEquals( WikiPage::selectFields(), Article::selectFields(), "Article static functions" ); - $this->assertEquals( null, Article::onArticleCreate( $title ), + $this->assertEquals( null, Article::onArticleCreate( $this->title ), "Article static functions" ); - $this->assertEquals( null, Article::onArticleDelete( $title ), + $this->assertEquals( null, Article::onArticleDelete( $this->title ), "Article static functions" ); - $this->assertEquals( null, ImagePage::onArticleEdit( $title ), + $this->assertEquals( null, ImagePage::onArticleEdit( $this->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" ); } + }