jenkins-bot has submitted this change and it was merged.

Change subject: Move DeferredStringifier into libs, add tests
......................................................................


Move DeferredStringifier into libs, add tests

Change-Id: I384d1a3854e957315584d30ec58c48c02fee6a2c
---
M autoload.php
R includes/libs/DeferredStringifier.php
A tests/phpunit/includes/libs/DeferredStringifierTest.php
3 files changed, 40 insertions(+), 1 deletion(-)

Approvals:
  Anomie: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/autoload.php b/autoload.php
index 674d4b0..72345fe 100644
--- a/autoload.php
+++ b/autoload.php
@@ -292,7 +292,7 @@
        'DateFormatter' => __DIR__ . '/includes/parser/DateFormatter.php',
        'DeadendPagesPage' => __DIR__ . 
'/includes/specials/SpecialDeadendpages.php',
        'DeferrableUpdate' => __DIR__ . 
'/includes/deferred/DeferredUpdates.php',
-       'DeferredStringifier' => __DIR__ . '/includes/DeferredStringifier.php',
+       'DeferredStringifier' => __DIR__ . 
'/includes/libs/DeferredStringifier.php',
        'DeferredUpdates' => __DIR__ . '/includes/deferred/DeferredUpdates.php',
        'DeleteAction' => __DIR__ . '/includes/actions/DeleteAction.php',
        'DeleteArchivedFiles' => __DIR__ . 
'/maintenance/deleteArchivedFiles.php',
diff --git a/includes/DeferredStringifier.php 
b/includes/libs/DeferredStringifier.php
similarity index 100%
rename from includes/DeferredStringifier.php
rename to includes/libs/DeferredStringifier.php
diff --git a/tests/phpunit/includes/libs/DeferredStringifierTest.php 
b/tests/phpunit/includes/libs/DeferredStringifierTest.php
new file mode 100644
index 0000000..9aaf113
--- /dev/null
+++ b/tests/phpunit/includes/libs/DeferredStringifierTest.php
@@ -0,0 +1,39 @@
+<?php
+
+class DeferredStringifierTest extends PHPUnit_Framework_TestCase {
+
+       /**
+        * @covers DeferredStringifier
+        * @dataProvider provideToString
+        */
+       public function testToString( $params, $expected ) {
+               $class = new ReflectionClass( 'DeferredStringifier' );
+               $ds = $class->newInstanceArgs( $params );
+               $this->assertEquals( $expected, (string)$ds );
+       }
+
+       public static function provideToString() {
+               return array(
+                       // No args
+                       array( array( function() {
+                               return 'foo';
+                       } ), 'foo' ),
+                       // Has args
+                       array( array( function( $i ) {
+                               return $i;
+                       }, 'bar' ), 'bar' ),
+               );
+       }
+
+       /**
+        * Verify that the callback is not called if
+        * it is never converted to a string
+        */
+       public function testCallbackNotCalled() {
+               $ds = new DeferredStringifier( function() {
+                       throw new Exception( 'This should not be reached!' );
+               } );
+               // No exception was thrown
+               $this->assertTrue( true );
+       }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I384d1a3854e957315584d30ec58c48c02fee6a2c
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Anomie <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to