- Timestamp:
- 10/03/2025 01:37:52 AM (7 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r60195 r60893 1849 1849 $this->assertArrayHasKey( 'self', $links ); 1850 1850 $this->assertArrayHasKey( 'author', $links ); 1851 $this->assertArrayNotHasKey( 'post', $links ); 1851 1852 1852 1853 $this->assertCount( 1, $links['author'] ); 1853 1854 $this->assertArrayHasKey( 'embeddable', $links['author'][0]['attributes'] ); 1854 1855 $this->assertTrue( $links['author'][0]['attributes']['embeddable'] ); 1856 } 1857 1858 /** 1859 * @ticket 64034 1860 */ 1861 public function test_links_contain_parent() { 1862 wp_set_current_user( self::$editor_id ); 1863 1864 $post = self::factory()->post->create( 1865 array( 1866 'post_type' => 'post', 1867 'post_status' => 'publish', 1868 'post_title' => 'Test Post', 1869 ) 1870 ); 1871 $attachment = self::factory()->attachment->create_object( 1872 array( 1873 'file' => self::$test_file, 1874 'post_author' => self::$editor_id, 1875 'post_parent' => $post, 1876 'post_mime_type' => 'image/jpeg', 1877 ) 1878 ); 1879 1880 $this->assertGreaterThan( 0, $attachment ); 1881 1882 $request = new WP_REST_Request( 'GET', "/wp/v2/media/{$attachment}" ); 1883 $request->set_query_params( array( 'context' => 'edit' ) ); 1884 1885 $response = rest_get_server()->dispatch( $request ); 1886 $links = $response->get_links(); 1887 1888 $this->assertArrayHasKey( 'self', $links ); 1889 $this->assertArrayHasKey( 'author', $links ); 1890 $this->assertArrayHasKey( 'post', $links ); 1891 1892 $this->assertCount( 1, $links['author'] ); 1893 $this->assertSame( rest_url( '/wp/v2/posts/' . $post ), $links['post'][0]['href'] ); 1894 $this->assertSame( 'post', $links['post'][0]['attributes']['post_type'] ); 1895 $this->assertSame( $post, $links['post'][0]['attributes']['id'] ); 1896 $this->assertTrue( $links['post'][0]['attributes']['embeddable'] ); 1855 1897 } 1856 1898
Note: See TracChangeset
for help on using the changeset viewer.