class BlockTest extends MediaWikiLangTestCase {
private $block, $madeAt;
+
+ /* variable used to save up the blockID we insert in this test suite */
+ private $blockId;
function setUp() {
global $wgContLang;
}
function addDBData() {
+ //$this->dumpBlocks();
$user = User::newFromName( 'UTBlockee' );
if( $user->getID() == 0 ) {
$this->madeAt = wfTimestamp( TS_MW );
$this->block->insert();
+ // save up ID for use in assertion. Since ID is an autoincrement,
+ // its value might change depending on the order the tests are run.
+ // ApiBlockTest insert its own blocks!
+ $this->blockId = $this->block->getId();
}
-
+
+ /**
+ * debug function : dump the ipblocks table
+ */
+ function dumpBlocks() {
+ $v = $this->db->query( 'SELECT * FROM unittest_ipblocks' );
+ print "Got " . $v->numRows() . " rows. Full dump follow:\n";
+ foreach( $v as $row ) {
+ print_r( $row );
+ }
+ }
+
function testInitializerFunctionsReturnCorrectBlock() {
-
+ // $this->dumpBlocks();
+
$this->assertTrue( $this->block->equals( Block::newFromTarget('UTBlockee') ), "newFromTarget() returns the same block as the one that was made");
- $this->assertTrue( $this->block->equals( Block::newFromID( 1 ) ), "newFromID() returns the same block as the one that was made");
+ $this->assertTrue( $this->block->equals( Block::newFromID( $this->blockId ) ), "newFromID() returns the same block as the one that was made");
}