X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2FtestHelpers.inc;h=818b24e23cc0be67600e2a5a116b7b0155adb59c;hb=39d981e8b547991a08c8f22afde4e4b33c624ff1;hp=6ff2b24643f33f879401d3494ab68dfd00accdcb;hpb=092cd8ee317d31877bdf87a96d3de240e39c7859;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/testHelpers.inc b/tests/testHelpers.inc index 6ff2b24643..818b24e23c 100644 --- a/tests/testHelpers.inc +++ b/tests/testHelpers.inc @@ -664,3 +664,37 @@ class DelayedParserTest { } } + +/** + * 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 ); + } +}