[JobQueue] Added unit tests for job queue code.
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
index 19736ee..dfc5881 100644 (file)
@@ -862,6 +862,46 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                }
        }
 
+       /**
+        * Check whether we have the 'gzip' commandline utility, will skip
+        * the test whenever "gzip -V" fails.
+        *
+        * Result is cached at the process level.
+        *
+        * @return bool
+        *
+        * @since 1.21
+        */
+       protected function checkHasGzip() {
+               static $haveGzip;
+
+               if( $haveGzip === null ) {
+                       $retval = null;
+                       wfShellExec( 'gzip -V', $retval );
+                       $haveGzip = ($retval === 0);
+               }
+
+               if( !$haveGzip ) {
+                       $this->markTestSkipped( "Skip test, requires the gzip utility in PATH" );
+               }
+
+               return $haveGzip;
+       }
+
+       /**
+        * Check if $extName is a loaded PHP extension, will skip the
+        * test whenever it is not loaded.
+        *
+        * @since 1.21
+        */
+       protected function checkPHPExtension( $extName ) {
+               $loaded = extension_loaded( $extName );
+               if( ! $loaded ) {
+                       $this->markTestSkipped( "PHP extension '$extName' is not loaded, skipping." );
+               }
+               return $loaded;
+       }
+
        /**
         * Asserts that an exception of the specified type occurs when running
         * the provided code.