r91376 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91375‎ | r91376 | r91377 >
Date:17:51, 3 July 2011
Author:hashar
Status:ok
Tags:
Comment:
split tests for ArticleTest
Modified paths:
  • /trunk/phase3/tests/phpunit/includes/ArticleTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/ArticleTest.php
@@ -1,34 +1,66 @@
22 <?php
33
44 class ArticleTest extends MediaWikiTestCase {
5 - function testBCMagic() {
6 - $title = Title::makeTitle( NS_MAIN, 'somePage' );
7 - $article = new Article( $title );
8 -
9 - $this->assertEquals( -1, $article->mCounter, "Article __get magic" );
105
11 - $article->mCounter = 2;
12 - $this->assertEquals( 2, $article->mCounter, "Article __set magic" );
 6+ private $title; // holds a Title object
 7+ private $article; // holds an article
138
14 - $this->assertEquals( 2, $article->getCount(), "Article __call magic" );
 9+ /** creates a title object and its article object */
 10+ function setUp() {
 11+ $this->title = Title::makeTitle( NS_MAIN, 'somePage' );
 12+ $this->article = new Article( $this->title );
1513
 14+ }
 15+
 16+ /** cleanup title object and its article object */
 17+ function tearDown() {
 18+ $this->title = null;
 19+ $this->article = null;
 20+
 21+ }
 22+
 23+ function testImplementsGetMagic() {
 24+ $this->assertEquals( -1, $this->article->mCounter, "Article __get magic" );
 25+ }
 26+
 27+ /**
 28+ * @depends testImplementsGetMagic
 29+ */
 30+ function testImplementsSetMagic() {
 31+
 32+ $this->article->mCounter = 2;
 33+ $this->assertEquals( 2, $this->article->mCounter, "Article __set magic" );
 34+ }
 35+
 36+ /**
 37+ * @depends testImplementsSetMagic
 38+ */
 39+ function testImplementsCallMagic() {
 40+ $this->article->mCounter = 33;
 41+ $this->assertEquals( 33, $this->article->getCount(), "Article __call magic" );
 42+ }
 43+
 44+ function testGetOrSetOnNewProperty() {
 45+ $this->article->ext_someNewProperty = 12;
 46+ $this->assertEquals( 12, $this->article->ext_someNewProperty,
 47+ "Article get/set magic on new field" );
 48+
 49+ $this->article->ext_someNewProperty = -8;
 50+ $this->assertEquals( -8, $this->article->ext_someNewProperty,
 51+ "Article get/set magic on update to new field" );
 52+ }
 53+
 54+ function testStaticFunctions() {
1655 $this->assertEquals( WikiPage::selectFields(), Article::selectFields(),
1756 "Article static functions" );
18 - $this->assertEquals( null, Article::onArticleCreate( $title ),
 57+ $this->assertEquals( null, Article::onArticleCreate( $this->title ),
1958 "Article static functions" );
20 - $this->assertEquals( null, Article::onArticleDelete( $title ),
 59+ $this->assertEquals( null, Article::onArticleDelete( $this->title ),
2160 "Article static functions" );
22 - $this->assertEquals( null, ImagePage::onArticleEdit( $title ),
 61+ $this->assertEquals( null, ImagePage::onArticleEdit( $this->title ),
2362 "Article static functions" );
2463 $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ),
2564 "Article static functions" );
 65+ }
2666
27 - $article->ext_someNewProperty = 12;
28 - $this->assertEquals( 12, $article->ext_someNewProperty,
29 - "Article get/set magic on new field" );
30 -
31 - $article->ext_someNewProperty = -8;
32 - $this->assertEquals( -8, $article->ext_someNewProperty,
33 - "Article get/set magic on update to new field" );
34 - }
3567 }

Status & tagging log