Skip to content

Commit

Permalink
1.x Fix tests failing with WordPress 6.4 (#2964)
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Apr 10, 2024
1 parent 4e90b28 commit 72d68f8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/Timber_UnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,16 @@ protected function callMethod($obj, $name, array $args = [])
$method->setAccessible(true);
return $method->invokeArgs($obj, $args);
}

public function isWordPressVersion(string $version, string $operator = '=')
{
return version_compare($GLOBALS['wp_version'], $version, $operator);
}

public function skipForWordpressVersion(string $version, string $operator = '<')
{
if ($this->isWordPressVersion($version, $operator)) {
$this->markTestSkipped("This test requires WordPress version $version or higher.");
}
}
}
24 changes: 24 additions & 0 deletions tests/test-timber-wp-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ function testFunctionFire(){
}

function testFooterOnFooterFW(){
if ($this->isWordPressVersion('6.4', '>=')) {
$this->setExpectedDeprecated('the_block_template_skip_link');
}

global $wp_scripts;
$wp_scripts = null;
wp_enqueue_script( 'jquery', false, array(), false, true );
Expand All @@ -26,6 +30,10 @@ function testFooterOnFooterFW(){
}

function testFooterAlone(){
if ($this->isWordPressVersion('6.4', '>=')) {
$this->setExpectedDeprecated('the_block_template_skip_link');
}

global $wp_scripts;
$wp_scripts = null;
wp_enqueue_script( 'jquery', false, array(), false, true );
Expand All @@ -44,6 +52,10 @@ function testDoubleAction(){
}

function testDoubleActionWPFooter(){
if ($this->isWordPressVersion('6.4', '>=')) {
$this->setExpectedDeprecated('the_block_template_skip_link');
}

global $wp_scripts;
$wp_scripts = null;
add_action('wp_footer', 'echo_junk');
Expand All @@ -55,6 +67,10 @@ function testDoubleActionWPFooter(){
}

function testInTwig(){
if ($this->isWordPressVersion('6.4', '>=')) {
$this->setExpectedDeprecated('the_block_template_skip_link');
}

global $wp_scripts;
$wp_scripts = null;
wp_enqueue_script( 'jquery', false, array(), false, true );
Expand All @@ -63,6 +79,10 @@ function testInTwig(){
}

function testInTwigString(){
if ($this->isWordPressVersion('6.4', '>=')) {
$this->setExpectedDeprecated('the_block_template_skip_link');
}

global $wp_scripts;
$wp_scripts = null;
wp_enqueue_script( 'jquery', false, array(), false, true );
Expand All @@ -71,6 +91,10 @@ function testInTwigString(){
}

function testAgainstFooterFunctionOutput(){
if ($this->isWordPressVersion('6.4', '>=')) {
$this->setExpectedDeprecated('the_block_template_skip_link');
}

global $wp_scripts;
$wp_scripts = null;
wp_enqueue_script( 'colorpicker', false, array(), false, true);
Expand Down

0 comments on commit 72d68f8

Please sign in to comment.