28fe3c0925380595d60c2b6e7aad2316f728223b
[lhc/web/wiklou.git] / tests / phpunit / includes / BlockTest.php
1 <?php
2
3 class BlockTest extends MediaWikiTestCase {
4
5 private $block, $madeAt;
6
7 function setUp() {
8 global $wgContLang;
9 $wgContLang = Language::factory( 'en' );
10 }
11
12 function tearDown() {
13 }
14
15 function addDBData() {
16
17 $user = User::newFromName( 'UTBlockee' );
18 if( $user->getID() == 0 ) {
19 $user->addToDatabase();
20 $user->setPassword( 'UTBlockeePassword' );
21
22 $user->saveSettings();
23 }
24
25 $this->block = new Block( 'UTBlockee', 1, 0,
26 'Parce que'
27 );
28 $this->madeAt = wfTimestamp( TS_MW );
29
30 $this->block->insert();
31 }
32
33 function testInitializerFunctionsReturnCorrectBlock() {
34
35 $this->assertTrue( $this->block->equals( Block::newFromDB('UTBlockee') ), "newFromDB() returns the same block as the one that was made");
36
37 $this->assertTrue( $this->block->equals( Block::newFromID( 1 ) ), "newFromID() returns the same block as the one that was made");
38
39 }
40
41 /**
42 * per bug 26425
43 */
44 function testBug26425BlockTimestampDefaultsToTime() {
45
46 $this->assertEquals( $this->madeAt, $this->block->mTimestamp, "If no timestamp is specified, the block is recorded as time()");
47
48 }
49
50 }
51