wiki.techinc.nl/tests/phpunit/includes/BlockTest.php
2011-05-01 23:02:27 +00:00

52 lines
1.1 KiB
PHP

<?php
/**
* @group Database
*/
class BlockTest extends MediaWikiLangTestCase {
private $block, $madeAt;
function setUp() {
global $wgContLang;
parent::setUp();
$wgContLang = Language::factory( 'en' );
}
function addDBData() {
$user = User::newFromName( 'UTBlockee' );
if( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTBlockeePassword' );
$user->saveSettings();
}
$this->block = new Block( 'UTBlockee', 1, 0,
'Parce que'
);
$this->madeAt = wfTimestamp( TS_MW );
$this->block->insert();
}
function testInitializerFunctionsReturnCorrectBlock() {
$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");
}
/**
* per bug 26425
*/
function testBug26425BlockTimestampDefaultsToTime() {
$this->assertEquals( $this->madeAt, $this->block->mTimestamp, "If no timestamp is specified, the block is recorded as time()");
}
}