Skip to content

Commit

Permalink
Update WP_Query_404_Guard.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuasha420 committed Jun 28, 2023
1 parent 968965b commit 136eb77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion includes/Core/Tags/Guards/WP_Query_404_Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Google\Site_Kit\Core\Guards\Guard_Interface;

/**
* Base class for a module tag guard.
* Class for WP_Query 404 guard.
*
* @since n.e.x.t
* @access private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,22 @@

class WP_Query_404_GuardTest extends TestCase {

/**
* Tag_Guard object.
*
* @var WP_Query_404_Guard
*/
private $guard;

public function set_up() {
parent::set_up();
$this->guard = new WP_Query_404_Guard();
}

public function test_can_activate() {
$guard = new WP_Query_404_Guard();

$this->go_to( '/' );

$this->assertQueryTrue( 'is_home', 'is_front_page' );
$this->assertTrue( $this->guard->can_activate(), 'Should return TRUE when the current page exists (is_home).' );
$this->assertTrue( $guard->can_activate(), 'Should return TRUE when the current page exists (is_home).' );
}

public function test_cant_activate_on_404() {
$guard = new WP_Query_404_Guard();

$this->go_to( '/?p=123456789' );

$this->assertQueryTrue( 'is_404' );
$this->assertFalse( $this->guard->can_activate(), 'Should return FALSE when the current page doesnt exist (is_404).' );
$this->assertFalse( $guard->can_activate(), 'Should return FALSE when the current page doesnt exist (is_404).' );
}

}

0 comments on commit 136eb77

Please sign in to comment.