@@ 223-230 (lines=8) @@ | ||
220 | /** |
|
221 | * Tests whether a third-party domain can be used in a block. |
|
222 | */ |
|
223 | public function test_validate_block_embed_third_party_url() { |
|
224 | $url = 'https://example.org'; |
|
225 | $allowed_hosts = array( 'wordpress.com' ); |
|
226 | ||
227 | $validated_url = Jetpack_Gutenberg::validate_block_embed_url( $url, $allowed_hosts ); |
|
228 | ||
229 | $this->assertFalse( $validated_url ); |
|
230 | } |
|
231 | ||
232 | /** |
|
233 | * Tests whether a random string (not a URL) can be used in a block. |
|
@@ 247-254 (lines=8) @@ | ||
244 | /** |
|
245 | * Tests whether a schemeless URL can be used in a block. |
|
246 | */ |
|
247 | public function test_validate_block_embed_scheme() { |
|
248 | $url = 'wordpress.com'; |
|
249 | $allowed_hosts = array( 'wordpress.com' ); |
|
250 | ||
251 | $validated_url = Jetpack_Gutenberg::validate_block_embed_url( $url, $allowed_hosts ); |
|
252 | ||
253 | $this->assertFalse( $validated_url ); |
|
254 | } |
|
255 | ||
256 | /** |
|
257 | * Tests whether a URL belonging to a whitelisted list can be used in a block. |
|
@@ 259-266 (lines=8) @@ | ||
256 | /** |
|
257 | * Tests whether a URL belonging to a whitelisted list can be used in a block. |
|
258 | */ |
|
259 | public function test_validate_block_embed_url() { |
|
260 | $url = 'https://wordpress.com/tos/'; |
|
261 | $allowed_hosts = array( 'wordpress.com' ); |
|
262 | ||
263 | $validated_url = Jetpack_Gutenberg::validate_block_embed_url( $url, $allowed_hosts ); |
|
264 | ||
265 | $this->assertEquals( $url, $validated_url ); |
|
266 | } |
|
267 | ||
268 | /** |
|
269 | * Tests whether a URL matches a specific regex. |