Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sirreal committed Nov 11, 2024
1 parent 766a3ad commit 9c76c73
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,38 @@ public function test_evaluate_value_negation() {
$this->assertFalse( $result );
}

/**
* Tests that the `evaluate` method operates correctly when used with the
* negation operator (!) with non-existent paths.
*
* @ticket 62374
*
* @covers ::evaluate
*/
public function test_evaluate_value_negation_non_existent_path() {
$this->interactivity->state( 'myPlugin', array() );
$this->interactivity->state( 'otherPlugin', array() );
$this->set_internal_context_stack(
array(
'myPlugin' => array(),
'otherPlugin' => array(),
)
);
$this->set_internal_namespace_stack( 'myPlugin' );

$result = $this->evaluate( '!state.missing' );
$this->assertTrue( $result );

$result = $this->evaluate( '!context.missing' );
$this->assertTrue( $result );

$result = $this->evaluate( 'otherPlugin::!state.deeply.nested.missing' );
$this->assertTrue( $result );

$result = $this->evaluate( 'otherPlugin::!context.deeply.nested.missing' );
$this->assertTrue( $result );
}

/**
* Tests the `evaluate` method with non-existent paths.
*
Expand Down

0 comments on commit 9c76c73

Please sign in to comment.