Changeset 36533 for trunk/tests/phpunit/tests/rest-api/rest-server.php
- Timestamp:
- 02/16/2016 02:18:34 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-server.php
r36531 r36533 401 401 } 402 402 403 public function test_link_curies() { 404 $response = new WP_REST_Response(); 405 $response->add_link( 'https://api.w.org/term', 'http://example.com/' ); 406 407 $data = $this->server->response_to_data( $response, false ); 408 $links = $data['_links']; 409 410 $this->assertArrayHasKey( 'wp:term', $links ); 411 $this->assertArrayHasKey( 'curies', $links ); 412 } 413 414 public function test_custom_curie_link() { 415 $response = new WP_REST_Response(); 416 $response->add_link( 'http://mysite.com/contact.html', 'http://example.com/' ); 417 418 add_filter( 'rest_response_link_curies', array( $this, 'add_custom_curie' ) ); 419 420 $data = $this->server->response_to_data( $response, false ); 421 $links = $data['_links']; 422 423 $this->assertArrayHasKey( 'my_site:contact', $links ); 424 $this->assertArrayHasKey( 'curies', $links ); 425 } 426 427 /** 428 * Helper callback to add a new custom curie via a filter. 429 * 430 * @param array $curies 431 * @return array 432 */ 433 public function add_custom_curie( $curies ) { 434 $curies[] = array( 435 'name' => 'my_site', 436 'href' => 'http://mysite.com/{rel}.html', 437 'templated' => true, 438 ); 439 return $curies; 440 } 441 403 442 /** 404 443 * @depends test_link_embedding
Note: See TracChangeset
for help on using the changeset viewer.