Skip to content

Commit 7de15eb

Browse files
committed
HTML API: Tests should use expectedIncorrectUsage phpunit annotation
Some tests in the HTML API test suite use `setExpectedIncorrectUsage`. The annotation `@expectedIncorrectUsage` can be used to simplify the tests. Developed in #6449 Discussed in https://core.trac.wordpress.org/ticket/61080 Fixes #61080. Props dmsnell, jonsurrell. git-svn-id: https://develop.svn.wordpress.org/trunk@58048 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 81882dd commit 7de15eb

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

tests/phpunit/tests/html-api/wpHtmlProcessor.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,10 @@ class Tests_HtmlApi_WpHtmlProcessor extends WP_UnitTestCase {
3030
* @ticket 58517
3131
*
3232
* @covers WP_HTML_Processor::__construct
33+
* @expectedIncorrectUsage WP_HTML_Processor::__construct
3334
*/
3435
public function test_warns_that_the_static_creator_methods_should_be_called_instead_of_the_public_constructor() {
35-
$this->setExpectedIncorrectUsage( 'WP_HTML_Processor::__construct' );
36-
3736
new WP_HTML_Processor( '<p>Light roast.</p>' );
38-
39-
$this->assertNotNull(
40-
$this->caught_doing_it_wrong['WP_HTML_Processor::__construct'],
41-
"Calling the public constructor should warn to call the static creator methods instead, but didn't."
42-
);
4337
}
4438

4539
/**

tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ public function test_updates_bookmark_for_deletions_before_both_sides() {
414414
* @ticket 56299
415415
*
416416
* @covers WP_HTML_Tag_Processor::set_bookmark
417+
* @expectedIncorrectUsage WP_HTML_Tag_Processor::set_bookmark
417418
*/
418419
public function test_limits_the_number_of_bookmarks() {
419420
$processor = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
@@ -423,7 +424,6 @@ public function test_limits_the_number_of_bookmarks() {
423424
$this->assertTrue( $processor->set_bookmark( "bookmark $i" ), "Could not allocate the bookmark #$i" );
424425
}
425426

426-
$this->setExpectedIncorrectUsage( 'WP_HTML_Tag_Processor::set_bookmark' );
427427
$this->assertFalse( $processor->set_bookmark( 'final bookmark' ), "Allocated $i bookmarks, which is one above the limit" );
428428
}
429429

0 commit comments

Comments
 (0)