From c4befaf28c00f7fff90862aa269fac849e5239e7 Mon Sep 17 00:00:00 2001 From: X! Date: Tue, 28 Dec 2010 19:27:34 +0000 Subject: [PATCH] Add test to supplement Bug 26425 (followup to r79013) --- tests/phpunit/includes/BlockTest.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/includes/BlockTest.php b/tests/phpunit/includes/BlockTest.php index a4ae047f3b..28fe3c0925 100644 --- a/tests/phpunit/includes/BlockTest.php +++ b/tests/phpunit/includes/BlockTest.php @@ -2,7 +2,7 @@ class BlockTest extends MediaWikiTestCase { - private $block; + private $block, $madeAt; function setUp() { global $wgContLang; @@ -13,15 +13,19 @@ class BlockTest extends MediaWikiTestCase { } function addDBData() { + $user = User::newFromName( 'UTBlockee' ); - $user->addToDatabase(); - $user->setPassword( 'UTBlockeePassword' ); + if( $user->getID() == 0 ) { + $user->addToDatabase(); + $user->setPassword( 'UTBlockeePassword' ); - $user->saveSettings(); + $user->saveSettings(); + } $this->block = new Block( 'UTBlockee', 1, 0, - 'Parce que', wfTimestampNow() + 'Parce que' ); + $this->madeAt = wfTimestamp( TS_MW ); $this->block->insert(); } @@ -33,6 +37,15 @@ class BlockTest extends MediaWikiTestCase { $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()"); + + } } -- 2.20.1