- Timestamp:
- 07/11/2018 06:22:10 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r43087 r43437 1351 1351 } 1352 1352 1353 public function test_links_exist() { 1354 1355 wp_set_current_user( self::$editor_id ); 1356 1357 $post = self::factory()->attachment->create( array( 'post_author' => self::$editor_id ) ); 1358 $this->assertGreaterThan( 0, $post ); 1359 1360 $request = new WP_REST_Request( 'GET', "/wp/v2/media/{$post}" ); 1361 $request->set_query_params( array( 'context' => 'edit' ) ); 1362 1363 $response = rest_get_server()->dispatch( $request ); 1364 $links = $response->get_links(); 1365 1366 $this->assertArrayHasKey( 'self', $links ); 1367 } 1368 1369 public function test_publish_action_ldo_not_registered() { 1370 1371 $response = rest_get_server()->dispatch( new WP_REST_Request( 'OPTIONS', '/wp/v2/media' ) ); 1372 $data = $response->get_data(); 1373 $schema = $data['schema']; 1374 1375 $this->assertArrayHasKey( 'links', $schema ); 1376 $publish = wp_list_filter( $schema['links'], array( 'rel' => 'https://api.w.org/action-publish' ) ); 1377 1378 $this->assertCount( 0, $publish, 'LDO not found on schema.' ); 1379 } 1380 1381 public function test_publish_action_link_does_not_exists() { 1382 1383 wp_set_current_user( self::$editor_id ); 1384 1385 $post = self::factory()->attachment->create( array( 'post_author' => self::$editor_id ) ); 1386 $this->assertGreaterThan( 0, $post ); 1387 1388 $request = new WP_REST_Request( 'GET', "/wp/v2/media/{$post}" ); 1389 $request->set_query_params( array( 'context' => 'edit' ) ); 1390 1391 $response = rest_get_server()->dispatch( $request ); 1392 $links = $response->get_links(); 1393 1394 $this->assertArrayNotHasKey( 'https://api.w.org/action-publish', $links ); 1395 } 1396 1353 1397 public function tearDown() { 1354 1398 parent::tearDown();
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)