Index: trunk/phase3/tests/phpunit/includes/BlockTest.php |
— | — | @@ -6,6 +6,9 @@ |
7 | 7 | class BlockTest extends MediaWikiLangTestCase { |
8 | 8 | |
9 | 9 | private $block, $madeAt; |
| 10 | + |
| 11 | + /* variable used to save up the blockID we insert in this test suite */ |
| 12 | + private $blockId; |
10 | 13 | |
11 | 14 | function setUp() { |
12 | 15 | global $wgContLang; |
— | — | @@ -14,6 +17,7 @@ |
15 | 18 | } |
16 | 19 | |
17 | 20 | function addDBData() { |
| 21 | + //$this->dumpBlocks(); |
18 | 22 | |
19 | 23 | $user = User::newFromName( 'UTBlockee' ); |
20 | 24 | if( $user->getID() == 0 ) { |
— | — | @@ -29,13 +33,29 @@ |
30 | 34 | $this->madeAt = wfTimestamp( TS_MW ); |
31 | 35 | |
32 | 36 | $this->block->insert(); |
| 37 | + // save up ID for use in assertion. Since ID is an autoincrement, |
| 38 | + // its value might change depending on the order the tests are run. |
| 39 | + // ApiBlockTest insert its own blocks! |
| 40 | + $this->blockId = $this->block->getId(); |
33 | 41 | } |
34 | | - |
| 42 | + |
| 43 | + /** |
| 44 | + * debug function : dump the ipblocks table |
| 45 | + */ |
| 46 | + function dumpBlocks() { |
| 47 | + $v = $this->db->query( 'SELECT * FROM unittest_ipblocks' ); |
| 48 | + print "Got " . $v->numRows() . " rows. Full dump follow:\n"; |
| 49 | + foreach( $v as $row ) { |
| 50 | + print_r( $row ); |
| 51 | + } |
| 52 | + } |
| 53 | + |
35 | 54 | function testInitializerFunctionsReturnCorrectBlock() { |
36 | | - |
| 55 | + // $this->dumpBlocks(); |
| 56 | + |
37 | 57 | $this->assertTrue( $this->block->equals( Block::newFromTarget('UTBlockee') ), "newFromTarget() returns the same block as the one that was made"); |
38 | 58 | |
39 | | - $this->assertTrue( $this->block->equals( Block::newFromID( 1 ) ), "newFromID() returns the same block as the one that was made"); |
| 59 | + $this->assertTrue( $this->block->equals( Block::newFromID( $this->blockId ) ), "newFromID() returns the same block as the one that was made"); |
40 | 60 | |
41 | 61 | } |
42 | 62 | |