Index: trunk/phase3/tests/phpunit/includes/ArticleTest.php |
— | — | @@ -1,34 +1,66 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | 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" ); |
10 | 5 | |
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 |
13 | 8 | |
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 ); |
15 | 13 | |
| 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() { |
16 | 55 | $this->assertEquals( WikiPage::selectFields(), Article::selectFields(), |
17 | 56 | "Article static functions" ); |
18 | | - $this->assertEquals( null, Article::onArticleCreate( $title ), |
| 57 | + $this->assertEquals( null, Article::onArticleCreate( $this->title ), |
19 | 58 | "Article static functions" ); |
20 | | - $this->assertEquals( null, Article::onArticleDelete( $title ), |
| 59 | + $this->assertEquals( null, Article::onArticleDelete( $this->title ), |
21 | 60 | "Article static functions" ); |
22 | | - $this->assertEquals( null, ImagePage::onArticleEdit( $title ), |
| 61 | + $this->assertEquals( null, ImagePage::onArticleEdit( $this->title ), |
23 | 62 | "Article static functions" ); |
24 | 63 | $this->assertTrue( is_string( CategoryPage::getAutosummary( '', '', 0 ) ), |
25 | 64 | "Article static functions" ); |
| 65 | + } |
26 | 66 | |
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 | | - } |
35 | 67 | } |