Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/109478


Change subject: Expand MWTimestamp tests
......................................................................

Expand MWTimestamp tests

Change-Id: I00215ecd85b7403a05a75d5eaccbbd2819343624
---
M tests/phpunit/includes/MWTimestampTest.php
1 file changed, 38 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/78/109478/1

diff --git a/tests/phpunit/includes/MWTimestampTest.php 
b/tests/phpunit/includes/MWTimestampTest.php
index fccd53b..18b8fe7 100644
--- a/tests/phpunit/includes/MWTimestampTest.php
+++ b/tests/phpunit/includes/MWTimestampTest.php
@@ -12,6 +12,44 @@
        }
 
        /**
+        * @covers MWTimestamp::__construct
+        */
+       public function testConstructWithNoTimestamp() {
+               $timestamp = new MWTimestamp();
+               $this->assertInternalType( 'string', $timestamp->getTimestamp() 
);
+               $this->assertNotEmpty( $timestamp->getTimestamp() );
+               $this->assertNotEquals( false, strtotime( 
$timestamp->getTimestamp( TS_MW ) ) );
+       }
+
+       /**
+        * @covers MWTimestamp::__toString
+        */
+       public function testToString() {
+               $timestamp = new MWTimestamp( '1406833268' ); // Equivlant to 
20140731190108
+               $this->assertEquals( '1406833268', $timestamp->__toString() );
+       }
+
+       public function provideValidTimestampDifferences() {
+               return array(
+                       array( '1406833268','1406833269', '00 00 00 01' ),
+                       array( '1406833268','1406833329', '00 00 01 01' ),
+                       array( '1406833268','1406836929', '00 01 01 01' ),
+                       array( '1406833268','1406923329', '01 01 01 01' ),
+               );
+       }
+
+       /**
+        * @dataProvider provideValidTimestampDifferences
+        * @covers MWTimestamp::diff
+        */
+       public function testDiff( $timestamp1, $timestamp2, $expected ) {
+               $timestamp1 = new MWTimestamp( $timestamp1 );
+               $timestamp2 = new MWTimestamp( $timestamp2 );
+               $diff = $timestamp1->diff( $timestamp2 );
+               $this->assertEquals( $expected, $diff->format( '%D %H %I %S' ) 
);
+       }
+
+       /**
         * Test parsing of valid timestamps and outputing to MW format.
         * @dataProvider provideValidTimestamps
         * @covers MWTimestamp::getTimestamp

-- 
To view, visit https://gerrit.wikimedia.org/r/109478
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I00215ecd85b7403a05a75d5eaccbbd2819343624
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to