- Timestamp:
- 11/14/2016 04:35:35 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-schema-sanitization.php
r39104 r39222 77 77 } 78 78 79 public function test_type_array_nested() { 80 $schema = array( 81 'type' => 'array', 82 'items' => array( 83 'type' => 'array', 84 'items' => array( 85 'type' => 'number', 86 ), 87 ), 88 ); 89 $this->assertEquals( array( array( 1 ), array( 2 ) ), rest_sanitize_value_from_schema( array( array( 1 ), array( 2 ) ), $schema ) ); 90 $this->assertEquals( array( array( 1 ), array( 2 ) ), rest_sanitize_value_from_schema( array( array( '1' ), array( '2' ) ), $schema ) ); 91 } 92 79 93 public function test_type_array_as_csv() { 80 94 $schema = array( … … 111 125 $this->assertEquals( array( 'chicken', 'coleslaw' ), rest_sanitize_value_from_schema( 'chicken,coleslaw', $schema ) ); 112 126 } 127 128 public function test_type_array_is_associative() { 129 $schema = array( 130 'type' => 'array', 131 'items' => array( 132 'type' => 'string', 133 ), 134 ); 135 $this->assertEquals( array( '1', '2' ), rest_sanitize_value_from_schema( array( 'first' => '1', 'second' => '2' ), $schema ) ); 136 } 137 138 public function test_type_unknown() { 139 $schema = array( 140 'type' => 'lalala', 141 ); 142 $this->assertEquals( 'Best lyrics', rest_sanitize_value_from_schema( 'Best lyrics', $schema ) ); 143 $this->assertEquals( 1.10, rest_sanitize_value_from_schema( 1.10, $schema ) ); 144 $this->assertEquals( 1, rest_sanitize_value_from_schema( 1, $schema ) ); 145 } 146 147 public function test_no_type() { 148 $schema = array( 149 'type' => null, 150 ); 151 $this->assertEquals( 'Nothing', rest_sanitize_value_from_schema( 'Nothing', $schema ) ); 152 $this->assertEquals( 1.10, rest_sanitize_value_from_schema( 1.10, $schema ) ); 153 $this->assertEquals( 1, rest_sanitize_value_from_schema( 1, $schema ) ); 154 } 113 155 }
Note: See TracChangeset
for help on using the changeset viewer.