Index: trunk/phase3/tests/phpunit/includes/BlockTest.php |
— | — | @@ -28,7 +28,14 @@ |
29 | 29 | |
30 | 30 | $user->saveSettings(); |
31 | 31 | } |
32 | | - |
| 32 | + |
| 33 | + // Delete the last round's block if it's still there |
| 34 | + $oldBlock = Block::newFromTarget( 'UTBlockee' ); |
| 35 | + if ( $oldBlock ) { |
| 36 | + // An old block will prevent our new one from saving. |
| 37 | + $oldBlock->delete(); |
| 38 | + } |
| 39 | + |
33 | 40 | $this->block = new Block( 'UTBlockee', 1, 0, |
34 | 41 | self::REASON |
35 | 42 | ); |
— | — | @@ -38,7 +45,12 @@ |
39 | 46 | // save up ID for use in assertion. Since ID is an autoincrement, |
40 | 47 | // its value might change depending on the order the tests are run. |
41 | 48 | // ApiBlockTest insert its own blocks! |
42 | | - $this->blockId = $this->block->getId(); |
| 49 | + $newBlockId = $this->block->getId(); |
| 50 | + if ($newBlockId) { |
| 51 | + $this->blockId = $newBlockId; |
| 52 | + } else { |
| 53 | + throw new MWException( "Failed to insert block for BlockTest; old leftover block remaining?" ); |
| 54 | + } |
43 | 55 | } |
44 | 56 | |
45 | 57 | /** |