wiki.techinc.nl/tests/phpunit/includes/BlockTest.php

52 lines
1.1 KiB
PHP
Raw Normal View History

2010-12-28 19:12:27 +00:00
<?php
class BlockTest extends MediaWikiTestCase {
private $block, $madeAt;
2010-12-28 19:12:27 +00:00
function setUp() {
global $wgContLang;
$wgContLang = Language::factory( 'en' );
}
function tearDown() {
}
function addDBData() {
2010-12-28 19:12:27 +00:00
$user = User::newFromName( 'UTBlockee' );
if( $user->getID() == 0 ) {
$user->addToDatabase();
$user->setPassword( 'UTBlockeePassword' );
2010-12-28 19:12:27 +00:00
$user->saveSettings();
}
2010-12-28 19:12:27 +00:00
$this->block = new Block( 'UTBlockee', 1, 0,
'Parce que'
2010-12-28 19:12:27 +00:00
);
$this->madeAt = wfTimestamp( TS_MW );
2010-12-28 19:12:27 +00:00
$this->block->insert();
}
function testInitializerFunctionsReturnCorrectBlock() {
$this->assertTrue( $this->block->equals( Block::newFromDB('UTBlockee') ), "newFromDB() 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()");
}
2010-12-28 19:12:27 +00:00
}