Make WordPress Core

Changeset 58048


Ignore:
Timestamp:
04/26/2024 01:51:06 PM (2 years ago)
Author:
dmsnell
Message:

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 ​https://github.com/WordPress/wordpress-develop/pull/6449
Discussed in https://core.trac.wordpress.org/ticket/61080

Fixes #61080.
Props dmsnell, jonsurrell.

Location:
trunk/tests/phpunit/tests/html-api
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/html-api/wpHtmlProcessor.php

    r57508 r58048  
    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
  • trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php

    r57805 r58048  
    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() {
    … …  
    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        }
Note: See TracChangeset for help on using the changeset viewer.