Add test to supplement Bug 26425 (followup to r79013)
authorX! <soxred93@users.mediawiki.org>
Tue, 28 Dec 2010 19:27:34 +0000 (19:27 +0000)
committerX! <soxred93@users.mediawiki.org>
Tue, 28 Dec 2010 19:27:34 +0000 (19:27 +0000)
tests/phpunit/includes/BlockTest.php

index a4ae047..28fe3c0 100644 (file)
@@ -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()");
+               
+       }
 
 }