Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests so that expected output depends on SCRIPT_DEBUG value
  • Loading branch information
andrewserong committed Sep 16, 2022
commit 36bf56f625c7674afa1f65095c9b1b6fdc30e18b
68 changes: 57 additions & 11 deletions tests/phpunit/tests/theme/wpGetGlobalStylesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,18 +256,64 @@ public function test_should_enqueue_stored_styles() {
)
);

// If `SCRIPT_DEBUG` is defined as true, style output will be prettified.
wp_enqueue_stored_styles();

$this->assertEquals(
array( '.saruman{color:white;height:100px;border-style:solid;}' ),
wp_styles()->registered['core-block-supports']->extra['after'],
'Registered styles with handle of "core-block-supports" do not match expected value from Style Engine store.'
);

$this->assertEquals(
array( '.gandalf{color:grey;height:90px;border-style:dotted;}' ),
wp_styles()->registered['wp-style-engine-my-styles']->extra['after'],
'Registered styles with handle of "wp-style-engine-my-styles" do not match expected value from the Style Engine store.'
);
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
// In `-src` versions of WordPress, `defaults-constants.php` will set SCRIPT_DEBUG to true.
$this->assertEquals(
array(
implode(
'',
array(
"/**\n",
" * Core styles: block-supports\n",
" */\n",
".saruman {\n",
" color: white;\n",
" height: 100px;\n",
" border-style: solid;\n",
"}\n",
)
)
),
wp_styles()->registered['core-block-supports']->extra['after'],
'Registered styles with handle of "core-block-supports" do not match expected value from Style Engine store.'
);
} else {
// In production versions of WordPress, `defaults-constants.php` will set SCRIPT_DEBUG to false.
$this->assertEquals(
array( '.saruman{color:white;height:100px;border-style:solid;}' ),
wp_styles()->registered['core-block-supports']->extra['after'],
'Registered styles with handle of "core-block-supports" do not match expected value from Style Engine store.'
);
}

if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
// In `-src` versions of WordPress, `defaults-constants.php` will set SCRIPT_DEBUG to true.
$this->assertEquals(
array(
implode(
'',
array(
".gandalf {\n",
" color: grey;\n",
" height: 90px;\n",
" border-style: dotted;\n",
"}\n"
)
)
),
wp_styles()->registered['wp-style-engine-my-styles']->extra['after'],
'Registered styles with handle of "core-block-supports" do not match expected value from Style Engine store.'
);
} else {
// In production versions of WordPress, `defaults-constants.php` will set SCRIPT_DEBUG to false.
$this->assertEquals(
array( '.gandalf{color:grey;height:90px;border-style:dotted;}' ),
wp_styles()->registered['wp-style-engine-my-styles']->extra['after'],
'Registered styles with handle of "wp-style-engine-my-styles" do not match expected value from the Style Engine store.'
);
}
}
}