- Timestamp:
- 08/28/2019 03:07:03 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-post-meta-fields.php
r45807 r45903 2122 2122 2123 2123 /** 2124 * @ticket 47928 2125 */ 2126 public function test_update_meta_with_unchanged_array_values() { 2127 register_post_meta( 2128 'post', 2129 'list', 2130 array( 2131 'single' => true, 2132 'type' => 'array', 2133 'show_in_rest' => array( 2134 'schema' => array( 2135 'type' => 'array', 2136 'items' => array( 2137 'type' => 'string', 2138 ), 2139 ), 2140 ), 2141 ) 2142 ); 2143 2144 add_post_meta( self::$post_id, 'list', array( 'WordCamp' ) ); 2145 2146 $this->grant_write_permission(); 2147 2148 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 2149 $request->set_body_params( 2150 array( 2151 'meta' => array( 2152 'list' => array( 'WordCamp' ), 2153 ), 2154 ) 2155 ); 2156 2157 $response = rest_get_server()->dispatch( $request ); 2158 $this->assertEquals( 200, $response->get_status() ); 2159 2160 $data = $response->get_data(); 2161 $this->assertEquals( array( 'WordCamp' ), $data['meta']['list'] ); 2162 } 2163 2164 /** 2165 * @ticket 47928 2166 */ 2167 public function test_update_meta_with_unchanged_object_values() { 2168 register_post_meta( 2169 'post', 2170 'object', 2171 array( 2172 'single' => true, 2173 'type' => 'object', 2174 'show_in_rest' => array( 2175 'schema' => array( 2176 'type' => 'object', 2177 'properties' => array( 2178 'project' => array( 2179 'type' => 'string', 2180 ), 2181 ), 2182 ), 2183 ), 2184 ) 2185 ); 2186 2187 add_post_meta( self::$post_id, 'object', array( 'project' => 'WordCamp' ) ); 2188 2189 $this->grant_write_permission(); 2190 2191 $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 2192 $request->set_body_params( 2193 array( 2194 'meta' => array( 2195 'object' => array( 'project' => 'WordCamp' ), 2196 ), 2197 ) 2198 ); 2199 2200 $response = rest_get_server()->dispatch( $request ); 2201 $this->assertEquals( 200, $response->get_status() ); 2202 2203 $data = $response->get_data(); 2204 $this->assertEquals( array( 'project' => 'WordCamp' ), $data['meta']['object'] ); 2205 } 2206 2207 /** 2124 2208 * Internal function used to disable an insert query which 2125 2209 * will trigger a wpdb error for testing purposes.
Note: See TracChangeset
for help on using the changeset viewer.