private function xRescript(ScriptReorganizer_Type_Library $library, &$expected) { $library->load($this->source); $library->reformat(); $library->save($this->target); $this->assertTrue($expected === file_get_contents($this->target)); }
/* * Normally, this would be the standard way of instantiating a library type object, * just swap ScriptReorganizer_Type_Script with ScriptReorganizer_Type_Library. */ $script = new ScriptReorganizer_Type_Decorator_AddHeader( new ScriptReorganizer_Type_Script( new ScriptReorganizer_Strategy_Pack( true ) ) ); $path = realpath( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR; // do the job ... ;) try { $library->load( $path . 'source/preLibrary.php' ); } catch ( ScriptReorganizer_Exception $e ) { $tempFile = $path . 'source/tempLibrary.php'; $library->save( $tempFile ); /* * A script type object has been used, for a many-to-one file optimization has * already taken place, albeit a library type object would have done the job too. */ $script->load( $tempFile ); $script->reformat( $header ); $script->save( $path . 'target/Screo-packedLibrary.php' ); unlink( $tempFile );