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