- Timestamp:
- 11/18/2016 07:32:03 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-schema-validation.php
r39222 r39296 84 84 } 85 85 86 public function test_format_ip v4() {86 public function test_format_ip() { 87 87 $schema = array( 88 88 'type' => 'string', 89 'format' => 'ip v4',89 'format' => 'ip', 90 90 ); 91 92 // IPv4. 91 93 $this->assertTrue( rest_validate_value_from_schema( '127.0.0.1', $schema ) ); 92 94 $this->assertWPError( rest_validate_value_from_schema( '3333.3333.3333.3333', $schema ) ); 93 95 $this->assertWPError( rest_validate_value_from_schema( '1', $schema ) ); 96 97 // IPv6. 98 $this->assertTrue( rest_validate_value_from_schema( '::1', $schema ) ); // Loopback, compressed, non-routable. 99 $this->assertTrue( rest_validate_value_from_schema( '::', $schema ) ); // Unspecified, compressed, non-routable. 100 $this->assertTrue( rest_validate_value_from_schema( '0:0:0:0:0:0:0:1', $schema ) ); // Loopback, full. 101 $this->assertTrue( rest_validate_value_from_schema( '0:0:0:0:0:0:0:0', $schema ) ); // Unspecified, full. 102 $this->assertTrue( rest_validate_value_from_schema( '2001:DB8:0:0:8:800:200C:417A', $schema ) ); // Unicast, full. 103 $this->assertTrue( rest_validate_value_from_schema( 'FF01:0:0:0:0:0:0:101', $schema ) ); // Multicast, full. 104 $this->assertTrue( rest_validate_value_from_schema( '2001:DB8::8:800:200C:417A', $schema ) ); // Unicast, compressed. 105 $this->assertTrue( rest_validate_value_from_schema( 'FF01::101', $schema ) ); // Multicast, compressed. 106 $this->assertTrue( rest_validate_value_from_schema( 'fe80::217:f2ff:fe07:ed62', $schema ) ); 107 $this->assertWPError( rest_validate_value_from_schema( '', $schema ) ); // Empty string. 108 $this->assertWPError( rest_validate_value_from_schema( '2001:DB8:0:0:8:800:200C:417A:221', $schema ) ); // Unicast, full. 109 $this->assertWPError( rest_validate_value_from_schema( 'FF01::101::2', $schema ) ); // Multicast, compressed. 94 110 } 95 111
Note: See TracChangeset
for help on using the changeset viewer.