Skip to content

Commit

Permalink
Fix the test for ignore debug
Browse files Browse the repository at this point in the history
  • Loading branch information
bordoni committed Jun 12, 2024
1 parent d63e91f commit ef87d41
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/wpunit/AssetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,36 @@ public function it_should_locate_minified_versions_of_external_assets() {
/**
* @test
*/
public function it_should_locate_minified_versions_of_external_assets() {
public function it_should_properly_locate_minified_files_when_SCRIPT_DEBUG_is_on_but_ignored() {

Asset::add( 'fake3-script', 'fake3.js' )->register();

$this->assertTrue( Assets::init()->exists( 'fake3-script' ) );
$this->assertTrue( wp_script_is( 'fake3-script', 'registered' ) );
$this->assertEquals( 'fake3-script', Assets::init()->get( 'fake3-script' )->get_slug() );

$this->assert_minified_found( 'fake3', true, true, true );
$asset = Assets::init()->get( 'fake3-script' );

// The URL will always be the minified version, since we ignore the script debug.
$expected_url = get_site_url() . '/wp-content/plugins/assets/tests/_data/js/fake3.min.js';

Config::set_ignore_script_debug( true );

$this->set_const_value( 'SCRIPT_DEBUG', false );
$this->assertFalse( SCRIPT_DEBUG );

$this->assertEquals(
$expected_url,
$asset->get_url()
);

$this->set_const_value( 'SCRIPT_DEBUG', true );
$this->assertTrue( SCRIPT_DEBUG );

$this->assertEquals(
$expected_url,
$asset->get_url()
);
}

/**
Expand Down

0 comments on commit ef87d41

Please sign in to comment.