Changeset 33851
- Timestamp:
- 09/02/2015 02:19:21 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/EscUrl.php
r33064 r33851 31 31 } 32 32 33 function test_bare() { 34 $this->assertEquals( 'http://example.com', esc_url( 'example.com' ) ); 35 $this->assertEquals( 'http://localhost', esc_url( 'localhost' ) ); 36 $this->assertEquals( 'http://example.com/foo', esc_url( 'example.com/foo' ) ); 37 $this->assertEquals( 'http://баба.org/баба', esc_url( 'баба.org/баба' ) ); 38 } 39 40 function test_encoding() { 41 $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); 42 $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); 43 $this->assertEquals( 'http://example.com?foo=1&bar=2', esc_url( 'http://example.com?foo=1&bar=2' ) ); 44 } 45 33 46 function test_protocol() { 34 47 $this->assertEquals('http://example.com', esc_url('http://example.com')); 35 48 $this->assertEquals('', esc_url('nasty://example.com/')); 49 $this->assertEquals( '', esc_url( 'example.com', array( 50 'https', 51 ) ) ); 52 $this->assertEquals( '', esc_url( 'http://example.com', array( 53 'https', 54 ) ) ); 55 $this->assertEquals( 'https://example.com', esc_url( 'https://example.com', array( 56 'http', 'https', 57 ) ) ); 58 59 foreach ( wp_allowed_protocols() as $scheme ) { 60 $this->assertEquals( "{$scheme}://example.com", esc_url( "{$scheme}://example.com" ), $scheme ); 61 $this->assertEquals( "{$scheme}://example.com", esc_url( "{$scheme}://example.com", array( 62 $scheme, 63 ) ), $scheme ); 64 } 65 66 $this->assertTrue( ! in_array( 'data', wp_allowed_protocols(), true ) ); 67 $this->assertEquals( '', esc_url( 'data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D' ) ); 68 69 $this->assertTrue( ! in_array( 'foo', wp_allowed_protocols(), true ) ); 70 $this->assertEquals( 'foo://example.com', esc_url( 'foo://example.com', array( 71 'foo', 72 ) ) ); 73 36 74 } 37 75
Note: See TracChangeset
for help on using the changeset viewer.