1<?php 2 3/** 4 * @group plugin_siteexport 5 * @group plugins 6 */ 7class SiteexportJavaScriptEvaluation extends DokuWikiTest { 8 9 protected $pluginsEnabled = array('siteexport'); 10 11 public function test_javascript_evaluates() { 12 13 $dir = dirname(__FILE__) . '/phantomjs/'; 14 $compressed = $dir . 'compressed.source.js'; 15 $uncompressed = $dir . 'uncompressed.source.js'; 16 17 if (@unlink($compressed) === false || @unlink($uncompressed) === false) { 18 echo "Did not remove previous files"; 19 } 20 21 file_put_contents($uncompressed, $this->setUpJavascript(0)); 22 $this->assertFileExists($uncompressed, "The uncompressed javascript version does not exist."); 23 24 file_put_contents($compressed, $this->setUpJavascript(1)); 25 $this->assertFileExists($compressed, "The compressed javascript version does not exist."); 26 } 27 28 private function setUpJavascript($compress = 1) { 29 30 global $conf; 31 32 $_SERVER['SERVER_PORT'] = rand(); 33 $conf['compress'] = $compress; 34 35 ob_start(); 36 js_out(); 37 $js = ob_get_contents(); 38 ob_end_clean(); 39 40 return $js; 41 } 42}