X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2FtestHelpers.inc;h=818b24e23cc0be67600e2a5a116b7b0155adb59c;hb=4f18925d219fffe42b11276ffa42c5bec6c0fbe9;hp=1d9cf305aacdb39d4c9ba248fafe13ad13ba237a;hpb=726ec65bd76c43a1dc189e63cca1d83ff1a9fb46;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc index 1d9cf305aa..818b24e23c 100644 --- a/tests/testHelpers.inc +++ b/tests/testHelpers.inc @@ -333,8 +333,8 @@ class DbTestRecorder extends DbTestPreviewer { /** * Record an individual test item's success or failure to the db * - * @param $test String - * @param $result Boolean + * @param string $test + * @param bool $result */ function record( $test, $result ) { parent::record( $test, $result ); @@ -481,7 +481,7 @@ class TestFileIterator implements Iterator { } if ( $input == false || $result == false || - ( ( preg_match( '/\\bdisabled\\b/i', $this->sectionData['options'] ) && !$this->parserTest->runDisabled ) + ( ( preg_match( '/\\bdisabled\\b/i', $this->sectionData['options'] ) && !$this->parserTest->runDisabled ) || ( preg_match( '/\\bparsoid\\b/i', $this->sectionData['options'] ) && $result != 'html/php' && !$this->parserTest->runParsoid ) || !preg_match( "/" . $this->parserTest->regex . "/i", $this->sectionData['test'] ) ) ) { @@ -545,9 +545,9 @@ class TestFileIterator implements Iterator { * Throw an exception if it is not set, referencing current section * and adding the current file name and line number * - * @param $token String|Array: expected token(s) that should have been + * @param string|array $token Expected token(s) that should have been * mentioned before closing this section - * @param $fatal Boolean: true iff an exception should be thrown if + * @param bool $fatal True iff an exception should be thrown if * the section is not found. */ private function checkSection( $tokens, $fatal = true ) { @@ -618,6 +618,7 @@ class DelayedParserTest { /** * Called whenever we actually want to run the hook. * Should be the case if we found the parserTest is not disabled + * @param ParserTest|NewParserTest $parserTest */ public function unleash( &$parserTest ) { if ( !( $parserTest instanceof ParserTest || $parserTest instanceof NewParserTest ) ) { @@ -647,6 +648,7 @@ class DelayedParserTest { /** * Similar to ParserTest object but does not run anything * Use unleash() to really execute the hook + * @param string $hook */ public function requireHook( $hook ) { $this->hooks[] = $hook; @@ -655,9 +657,44 @@ class DelayedParserTest { /** * Similar to ParserTest object but does not run anything * Use unleash() to really execute the hook function + * @param string $fnHook */ public function requireFunctionHook( $fnHook ) { $this->fnHooks[] = $fnHook; } } + +/** + * Initialize and detect the DjVu files support + */ +class DjVuSupport { + + /** + * Initialises DjVu tools global with default values + */ + public function __construct() { + global $wgDjvuRenderer, $wgDjvuDump, $wgDjvuToXML, $wgFileExtensions; + + $wgDjvuRenderer = $wgDjvuRenderer ? $wgDjvuRenderer : '/usr/bin/ddjvu'; + $wgDjvuDump = $wgDjvuDump ? $wgDjvuDump : '/usr/bin/djvudump'; + $wgDjvuToXML = $wgDjvuToXML ? $wgDjvuToXML : '/usr/bin/djvutoxml'; + + if ( !in_array( 'djvu', $wgFileExtensions ) ) { + $wgFileExtensions[] = 'djvu'; + } + } + + /** + * Returns if the DjVu tools are usable + * + * @return bool + */ + public function isEnabled() { + global $wgDjvuRenderer, $wgDjvuDump, $wgDjvuToXML; + + return is_executable( $wgDjvuRenderer ) + && is_executable( $wgDjvuDump ) + && is_executable( $wgDjvuToXML ); + } +}