Skip to content

Commit

Permalink
Update tests checking the notice
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Apr 22, 2024
1 parent 1ef9ee6 commit 24199ab
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,32 @@ class Tests_Interactivity_API_WpInteractivityAPI extends WP_UnitTestCase {
*/
protected $interactivity;

/**
* Array of expected `_doing_it_wrong()` calls.
*
* @var string[]
*/
protected $expected_doing_it_wrong;

/**
* Set up.
*/
public function set_up() {
parent::set_up();
$this->interactivity = new WP_Interactivity_API();
$this->interactivity = new WP_Interactivity_API();
$this->expected_doing_it_wrong = array();
}

/**
* Declares an expected `_doing_it_wrong()` call from within a test.
*
* @since 4.2.0
*
* @param string $doing_it_wrong Name of the function, method, or class that appears in
* the first argument of the source `_doing_it_wrong()` call.
*/
public function setExpectedIncorrectUsage( $doing_it_wrong ) {
$this->expected_doing_it_wrong[] = $doing_it_wrong;
}

/**
Expand Down Expand Up @@ -609,6 +629,7 @@ public function test_process_directives_doesnt_change_html_if_contains_unbalance
$processed_html = $this->interactivity->process_directives( $html );
$p = new WP_HTML_Tag_Processor( $processed_html );
$p->next_tag();
$this->setExpectedIncorrectUsage( 'WP_Interactivity_API::process_directives_args' );
$this->assertNull( $p->get_attribute( 'id' ) );
}
}
Expand Down Expand Up @@ -639,7 +660,8 @@ public function test_process_directives_changes_html_if_contains_svgs() {
</header>
';
$processed_html = $this->interactivity->process_directives( $html );
$p = new WP_HTML_Tag_Processor( $processed_html );
$this->setExpectedIncorrectUsage( 'WP_Interactivity_API::process_directives_args' );
$p = new WP_HTML_Tag_Processor( $processed_html );
$p->next_tag( 'svg' );
$this->assertNull( $p->get_attribute( 'width' ) );
$p->next_tag( 'div' );
Expand Down Expand Up @@ -704,7 +726,8 @@ public function test_process_directives_change_html_if_contains_math() {
</header>
';
$processed_html = $this->interactivity->process_directives( $html );
$p = new WP_HTML_Tag_Processor( $processed_html );
$this->setExpectedIncorrectUsage( 'WP_Interactivity_API::process_directives_args' );
$p = new WP_HTML_Tag_Processor( $processed_html );
$p->next_tag( 'math' );
$this->assertNull( $p->get_attribute( 'id' ) );
$p->next_tag( 'div' );
Expand Down Expand Up @@ -737,7 +760,8 @@ public function test_process_directives_does_not_change_inner_html_in_math() {
</header>
';
$processed_html = $this->interactivity->process_directives( $html );
$p = new WP_HTML_Tag_Processor( $processed_html );
$this->setExpectedIncorrectUsage( 'WP_Interactivity_API::process_directives_args' );
$p = new WP_HTML_Tag_Processor( $processed_html );
$p->next_tag( 'div' );
$this->assertNull( $p->get_attribute( 'id' ) );
}
Expand Down

0 comments on commit 24199ab

Please sign in to comment.