get_url( 'flavortown', 'js' ); // All we are concerned about in this test is the js filename. Pop it off the end of the asset url. $parts = explode( '/', $result ); $final_file_name = array_pop( $parts ); // Since this can vary depending on the env the tests are running in, we will make this assertion based upon the SCRIPT_DEBUG value. $expected_value = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'flavortown.js' : 'flavortown.min.js'; $this->assertEquals( $expected_value, $final_file_name, 'the anticipated js file name should use .min when SCRIPT_DEBUG is off, and have no .min when SCRIPT_DEBUG is on.' ); } /** * Tests for should_use_minified_js_file */ public function test_should_use_minified_js_file() { $loader = Loader::get_instance(); // We will simulate a call with SCRIPT_DEBUG on. $script_debug = true; $this->assertFalse( $loader->should_use_minified_js_file( $script_debug ), 'Since unminifed js feature is TRUE/on, and script_debug is true, should_use_minified_js_file should return false' ); // Now we will simulate SCRIPT_DEBUG off/false. $script_debug = false; $this->assertTrue( $loader->should_use_minified_js_file( $script_debug ), 'Since unminifed js feature is TRUE/on, and script_debug is false, should_use_minified_js_file should return true' ); } }