Changeset 60972
- Timestamp:
- 10/19/2025 12:17:57 AM (5 weeks ago)
- Location:
- trunk/tests/phpunit/tests/oembed
- Files:
-
- 2 edited
- filterResult.php (modified) (10 diffs)
- filterTitleAttributes.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/oembed/filterResult.php
r58143 r60972 10 10 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), 'https://www.youtube.com/watch?v=72xdCU__XCk' ); 11 11 12 $this->assert Same( $html, $actual );12 $this->assertEqualHTML( $html, $actual ); 13 13 } 14 14 … … 17 17 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), 'http://example.com/sample-page/' ); 18 18 19 $matches = array(); 20 preg_match( '|src=".*#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches ); 21 22 $this->assertArrayHasKey( 1, $matches ); 23 $this->assertArrayHasKey( 2, $matches ); 24 $this->assertSame( $matches[1], $matches[2] ); 19 $processor = new WP_HTML_Tag_Processor( $actual ); 20 21 $this->assertTrue( 22 $processor->next_tag( 'IFRAME' ), 23 'Failed to find expected IFRAME element in filtered output.' 24 ); 25 26 $src = $processor->get_attribute( 'src' ); 27 $this->assertIsString( 28 $src, 29 isset( $src ) 30 ? 'Expected "src" attribute on IFRAME with string value but found boolean attribute instead.' 31 : 'Failed to find expected "src" attribute on IFRAME element.' 32 ); 33 34 $query_string = parse_url( $src, PHP_URL_FRAGMENT ); 35 $this->assertStringStartsWith( 36 '?', 37 $query_string, 38 'Should have found URL fragment in "src" attribute resembling a query string.' 39 ); 40 41 $query_string = substr( $query_string, 1 ); 42 $query_args = array(); 43 parse_str( $query_string, $query_args ); 44 45 $this->assertArrayHasKey( 46 'secret', 47 $query_args, 48 'Failed to find expected query arg "secret" in IFRAME "src" attribute.' 49 ); 50 51 $this->assertSame( 52 $query_args['secret'], 53 $processor->get_attribute( 'data-secret' ), 54 'Expected to find identical copy of secret from IFRAME "src" in the "data-secret" attribute.' 55 ); 25 56 } 26 57 … … 29 60 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 30 61 31 $this->assert Same( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual );62 $this->assertEqualHTML( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); 32 63 } 33 64 … … 42 73 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 43 74 44 $this->assert Same( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual );75 $this->assertEqualHTML( '<iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"></iframe>', $actual ); 45 76 } 46 77 … … 61 92 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 62 93 63 $matches = array(); 64 preg_match( '|src="https://wordpress.org#\?secret=([\w\d]+)" data-secret="([\w\d]+)"|', $actual, $matches ); 65 66 $this->assertArrayHasKey( 1, $matches ); 67 $this->assertArrayHasKey( 2, $matches ); 68 $this->assertSame( $matches[1], $matches[2] ); 94 $processor = new WP_HTML_Tag_Processor( $actual ); 95 96 $this->assertTrue( 97 $processor->next_tag( 'IFRAME' ), 98 'Failed to find expected IFRAME element in filtered output.' 99 ); 100 101 $src = $processor->get_attribute( 'src' ); 102 $this->assertMatchesRegularExpression( 103 '~^https://wordpress.org~', 104 $src, 105 'Failed to find expected "src" attribute on IFRAME element.' 106 ); 107 108 $query_string = parse_url( $src, PHP_URL_FRAGMENT ); 109 $this->assertStringStartsWith( 110 '?', 111 $query_string, 112 'Should have found URL fragment in "src" attribute resembling a query string.' 113 ); 114 115 $query_string = substr( $query_string, 1 ); 116 $query_args = array(); 117 parse_str( $query_string, $query_args ); 118 119 $this->assertArrayHasKey( 120 'secret', 121 $query_args, 122 'Failed to find expected query arg "secret" in IFRAME "src" attribute.' 123 ); 124 125 $this->assertSame( 126 $query_args['secret'], 127 $processor->get_attribute( 'data-secret' ), 128 'Expected to find identical copy of secret from IFRAME "src" in the "data-secret" attribute.' 129 ); 69 130 } 70 131 … … 72 133 $actual = wp_filter_oembed_result( 'some string', (object) array( 'type' => 'link' ), '' ); 73 134 74 $this->assert Same( 'some string', $actual );135 $this->assertEqualHTML( 'some string', $actual ); 75 136 } 76 137 … … 84 145 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 85 146 86 $this->assert Same( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;"></iframe>', $actual );147 $this->assertEqualHTML( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;"></iframe>', $actual ); 87 148 } 88 149 … … 91 152 $actual = wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ); 92 153 93 $this->assert Same( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;"></iframe>', $actual );154 $this->assertEqualHTML( '<blockquote class="wp-embedded-content"><a href=""></a></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" style="position: absolute; visibility: hidden;"></iframe>', $actual ); 94 155 } 95 156 … … 125 186 ); 126 187 $actual = _wp_oembed_get_object()->data2html( $data, 'https://untrusted.localhost' ); 127 $this->assert Same( $expected, $actual );188 $this->assertEqualHTML( $expected, $actual ); 128 189 } 129 190 … … 135 196 $actual = _oembed_filter_feed_content( wp_filter_oembed_result( $html, (object) array( 'type' => 'rich' ), '' ) ); 136 197 137 $this->assert Same( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" ></iframe>', $actual );198 $this->assertEqualHTML( '<blockquote class="wp-embedded-content"></blockquote><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted" ></iframe>', $actual ); 138 199 } 139 200 } -
trunk/tests/phpunit/tests/oembed/filterTitleAttributes.php
r49117 r60972 68 68 $actual = wp_filter_oembed_iframe_title_attribute( $html, (object) $oembed_data, $url ); 69 69 70 $this->assert Same( $expected, $actual );70 $this->assertEqualHTML( $expected, $actual ); 71 71 } 72 72 … … 85 85 remove_filter( 'oembed_iframe_title_attribute', array( $this, '_filter_oembed_iframe_title_attribute' ) ); 86 86 87 $this->assert Same( '<iframe title="Baz" src=""></iframe>', $actual );87 $this->assertEqualHTML( '<iframe title="Baz" src=""></iframe>', $actual ); 88 88 } 89 89 … … 102 102 remove_filter( 'oembed_iframe_title_attribute', array( $this, '_filter_oembed_iframe_title_attribute' ) ); 103 103 104 $this->assert Same( '<p title="Bar">Baz</p><iframe title="Baz" src=""></iframe>', $actual );104 $this->assertEqualHTML( '<p title="Bar">Baz</p><iframe title="Baz" src=""></iframe>', $actual ); 105 105 } 106 106
Note: See TracChangeset for help on using the changeset viewer.