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

Change subject: Add some additional test-cases for MediaWiki\quietCall()
......................................................................


Add some additional test-cases for MediaWiki\quietCall()

Test MediaWiki\quietCall() with different kinds of callables.

Change-Id: I43ec3af4d40fe1d6fc79c3d12af343555ab96ffb
---
M tests/FunctionsTest.php
1 file changed, 32 insertions(+), 1 deletion(-)

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



diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php
index 747da79..a393cf0 100644
--- a/tests/FunctionsTest.php
+++ b/tests/FunctionsTest.php
@@ -36,6 +36,14 @@
                $this->assertTrue( true );
        }
 
+       public static function dummyStaticMethod( $x ) {
+               return $x * 2;
+       }
+
+       public function dummyInstanceMethod( $x ) {
+               return $x * 2;
+       }
+
        /**
         * Ensure that MediaWiki\quietCall calls the callback function with the
         * correct parameters, that it returns the callback's return value, and
@@ -44,9 +52,32 @@
         * @covers MediaWiki\quietCall
         */
        public function testQuietCall() {
+               $double = function ( $num ) {
+                       return $num * 2;
+               };
+
                $this->assertEquals(
                        MediaWiki\quietCall( 'filemtime', __FILE__ ),
-                       filemtime( __FILE__ )
+                       filemtime( __FILE__ ),
+                       'MediaWiki\quietCall() with built-in function'
+               );
+
+               $this->assertEquals(
+                       MediaWiki\quietCall( 
'FunctionsTest::dummyStaticMethod', 24 ),
+                       FunctionsTest::dummyStaticMethod( 24 ),
+                       'MediaWiki\quietCall() with static method'
+               );
+
+               $this->assertEquals(
+                       MediaWiki\quietCall( array( $this, 
'dummyInstanceMethod' ), 24 ),
+                       $this->dummyInstanceMethod( 24 ),
+                       'MediaWiki\quietCall() with instance method'
+               );
+
+               $this->assertEquals(
+                       MediaWiki\quietCall( $double, 24 ),
+                       $double( 24 ),
+                       'MediaWiki\quietCall() with closure'
                );
 
                $this->assertFalse(

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I43ec3af4d40fe1d6fc79c3d12af343555ab96ffb
Gerrit-PatchSet: 1
Gerrit-Project: at-ease
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to