@@ -84,6 +84,15 @@ public static function tear_down_after_class()
8484 public function set_up ()
8585 {
8686 }
87+ /**
88+ * Sets the bcrypt cost option for password hashing during tests.
89+ *
90+ * @param array $options The options for password hashing.
91+ * @param string|int $algorithm The algorithm to use for hashing. This is a string in PHP 7.4+ and an integer in PHP 7.3 and earlier.
92+ */
93+ public function wp_hash_password_options (array $ options , $ algorithm ): array
94+ {
95+ }
8796 /**
8897 * After a test method runs, resets any state in WordPress the test method might have changed.
8998 */
@@ -556,6 +565,28 @@ public function normalizeDirectorySeparatorsInPath($path)
556565 public function assertQueryTrue (...$ prop )
557566 {
558567 }
568+ /**
569+ * Check HTML markup (including blocks) for semantic equivalence.
570+ *
571+ * Given two markup strings, assert that they translate to the same semantic HTML tree,
572+ * normalizing tag names, attribute names, and attribute order. Furthermore, attributes
573+ * and class names are sorted and deduplicated, and whitespace in style attributes
574+ * is normalized. Finally, block delimiter comments are recognized and normalized,
575+ * applying the same principles.
576+ *
577+ * @since 6.9.0
578+ *
579+ * @param string $expected The expected HTML.
580+ * @param string $actual The actual HTML.
581+ * @param string|null $fragment_context Optional. The fragment context, for example "<td>" expected HTML
582+ * must occur within "<table><tr>" fragment context. Default "<body>".
583+ * Only "<body>" or `null` are supported at this time.
584+ * Set to `null` to parse a full HTML document.
585+ * @param string|null $message Optional. The assertion error message.
586+ */
587+ public function assertEqualHTML (string $ expected , string $ actual , ?string $ fragment_context = '<body> ' , $ message = 'HTML markup was not equivalent. ' ): void
588+ {
589+ }
559590 /**
560591 * Helper function to convert a single-level array containing text strings to a named data provider.
561592 *
@@ -1700,12 +1731,13 @@ public function create_object($args, $legacy_parent = 0, $legacy_args = array())
17001731 {
17011732 }
17021733 /**
1703- * Saves an attachment.
1734+ * Saves a file as an attachment.
17041735 *
17051736 * @since 4.4.0
17061737 * @since 6.2.0 Returns a WP_Error object on failure.
17071738 *
1708- * @param string $file The file name to create attachment object for.
1739+ * @param string $file Full path to the file to create an attachment object for.
1740+ * The name of the file will be used as the attachment name.
17091741 * @param int $parent_post_id ID of the post to attach the file to.
17101742 *
17111743 * @return int|WP_Error The attachment ID on success, WP_Error object on failure.
@@ -2433,7 +2465,7 @@ public function remove_header($header)
24332465 /**
24342466 * Stores last set status.
24352467 *
2436- * @param int $code HTTP status.
2468+ * @param int $status HTTP status.
24372469 */
24382470 public function set_status ($ status )
24392471 {
@@ -3061,6 +3093,54 @@ public function print_summary()
30613093function wp_tests_options ($ value )
30623094{
30633095}
3096+ /* phpcs:disable WordPress.Security.EscapeOutput.ExceptionNotEscaped */
3097+ /**
3098+ * Generates representation of the semantic HTML tree structure.
3099+ *
3100+ * This is inspired by the representation used by the HTML5lib tests. It's been extended here for
3101+ * blocks to render the semantic structure of blocks and their attributes.
3102+ * The order of attributes and class names is normalized both for HTML tags and blocks,
3103+ * as is the whitespace in HTML tags' style attribute.
3104+ *
3105+ * For example, consider the following block markup:
3106+ *
3107+ * <!-- wp:separator {"className":"is-style-default has-custom-classname","style":{"spacing":{"margin":{"top":"50px","bottom":"50px"}}},"backgroundColor":"accent-1"} -->
3108+ * <hr class="wp-block-separator is-style-default has-custom-classname" style="margin-top: 50px; margin-bottom: 50px" />
3109+ * <!-- /wp:separator -->
3110+ *
3111+ * This will be represented as:
3112+ *
3113+ * BLOCK["core/separator"]
3114+ * {
3115+ * "backgroundColor": "accent-1",
3116+ * "className": "has-custom-classname is-style-default",
3117+ * "style": {
3118+ * "spacing": {
3119+ * "margin": {
3120+ * "top": "50px",
3121+ * "bottom": "50px"
3122+ * }
3123+ * }
3124+ * }
3125+ * }
3126+ * <hr>
3127+ * class="has-custom-classname is-style-default wp-block-separator"
3128+ * style="margin-top:50px;margin-bottom:50px;"
3129+ *
3130+ *
3131+ * @see https://github.com/WordPress/wordpress-develop/blob/trunk/tests/phpunit/data/html5lib-tests/tree-construction/README.md
3132+ *
3133+ * @since 6.9.0
3134+ *
3135+ * @throws WP_HTML_Unsupported_Exception|Exception If the markup could not be parsed.
3136+ *
3137+ * @param string $html Given test HTML.
3138+ * @param string|null $fragment_context Context element in which to parse HTML, such as BODY or SVG.
3139+ * @return string Tree structure of parsed HTML, if supported.
3140+ */
3141+ function build_visual_html_tree (string $ html , ?string $ fragment_context ): string
3142+ {
3143+ }
30643144/**
30653145 * Retrieves PHPUnit runner version.
30663146 *
@@ -3253,6 +3333,25 @@ function _unhook_block_registration()
32533333function _unhook_font_registration ()
32543334{
32553335}
3336+ /**
3337+ * Before the abilities API categories init action runs, unhook the core ability
3338+ * categories registration function to prevent core categories from being registered
3339+ * during tests.
3340+ *
3341+ * @since 6.9.0
3342+ */
3343+ function _unhook_core_ability_categories_registration ()
3344+ {
3345+ }
3346+ /**
3347+ * Before the abilities API init action runs, unhook the core abilities
3348+ * registration function to prevent core abilities from being registered during tests.
3349+ *
3350+ * @since 6.9.0
3351+ */
3352+ function _unhook_core_abilities_registration ()
3353+ {
3354+ }
32563355/**
32573356 * Helper method to return the global phpmailer instance defined in the bootstrap
32583357 *
0 commit comments