Changeset 44126
- Timestamp:
- 12/13/2018 10:41:47 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43767-43769
- Property svn:mergeinfo changed
-
trunk/phpunit.xml.dist
r42665 r44126 7 7 <testsuites> 8 8 <!-- Default test suite to run all tests --> 9 <testsuite >9 <testsuite name="default"> 10 10 <directory suffix=".php">tests/phpunit/tests</directory> 11 11 <exclude>tests/phpunit/tests/actions/closures.php</exclude> … … 14 14 <exclude>tests/phpunit/tests/image/editorImagick.php</exclude> 15 15 <exclude>tests/phpunit/tests/oembed/headers.php</exclude> 16 <exclude>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</exclude> 16 17 <file phpVersion="5.3.0">tests/phpunit/tests/actions/closures.php</file> 17 18 <file phpVersion="5.3.0">tests/phpunit/tests/image/editor.php</file> … … 19 20 <file phpVersion="5.3.0">tests/phpunit/tests/image/editorImagick.php</file> 20 21 <file phpVersion="5.3.0">tests/phpunit/tests/oembed/headers.php</file> 22 </testsuite> 23 <!-- Sets the DOING_AUTOSAVE constant, so needs to be run last --> 24 <testsuite name="restapi-autosave"> 25 <file>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</file> 21 26 </testsuite> 22 27 </testsuites> -
trunk/src/wp-includes/rest-api.php
r44123 r44126 193 193 $revisions_controller = new WP_REST_Revisions_Controller( $post_type->name ); 194 194 $revisions_controller->register_routes(); 195 } 196 197 if ( 'attachment' !== $post_type->name ) { 198 $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name ); 199 $autosaves_controller->register_routes(); 195 200 } 196 201 } -
trunk/src/wp-settings.php
r44118 r44126 231 231 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php' ); 232 232 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php' ); 233 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php' ); 233 234 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-taxonomies-controller.php' ); 234 235 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.php' ); -
trunk/tests/phpunit/multisite.xml
r41263 r44126 10 10 <testsuites> 11 11 <!-- Default test suite to run all tests --> 12 <testsuite >12 <testsuite name="default"> 13 13 <directory suffix=".php">tests</directory> 14 14 <exclude>tests/phpunit/tests/actions/closures.php</exclude> … … 16 16 <exclude>tests/phpunit/tests/image/editorGd.php</exclude> 17 17 <exclude>tests/phpunit/tests/image/editorImagick.php</exclude> 18 <!-- DOING_AUTOSAVE constant pollutes test suite --> 19 <!-- and there is a weird 5.2 edge case: https://core.trac.wordpress.org/ticket/45132 --> 20 <exclude>tests/rest-api/rest-autosaves-controller.php</exclude> 21 <exclude>tests/phpunit/tests/rest-api/rest-autosaves-controller.php</exclude> 18 22 <file phpVersion="5.3.0">tests/phpunit/tests/actions/closures.php</file> 19 23 <file phpVersion="5.3.0">tests/phpunit/tests/image/editor.php</file> -
trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php
r44107 r44126 90 90 '/wp/v2/posts/(?P<parent>[\\d]+)/revisions', 91 91 '/wp/v2/posts/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)', 92 '/wp/v2/posts/(?P<parent>[\\d]+)/autosaves', 93 '/wp/v2/posts/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)', 92 94 '/wp/v2/pages', 93 95 '/wp/v2/pages/(?P<id>[\\d]+)', 94 96 '/wp/v2/pages/(?P<parent>[\\d]+)/revisions', 95 97 '/wp/v2/pages/(?P<parent>[\\d]+)/revisions/(?P<id>[\\d]+)', 98 '/wp/v2/pages/(?P<parent>[\\d]+)/autosaves', 99 '/wp/v2/pages/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)', 96 100 '/wp/v2/media', 97 101 '/wp/v2/media/(?P<id>[\\d]+)', … … 162 166 $post_revision_id = $post_revisions[ count( $post_revisions ) - 1 ]->ID; 163 167 168 // Create an autosave. 169 wp_create_post_autosave( 170 array( 171 'post_ID' => $post_id, 172 'post_content' => 'Autosave post content.', 173 'post_type' => 'post', 174 ) 175 ); 176 164 177 $page_id = $this->factory->post->create( 165 178 array( … … 182 195 $page_revisions = array_values( wp_get_post_revisions( $page_id ) ); 183 196 $page_revision_id = $page_revisions[ count( $page_revisions ) - 1 ]->ID; 197 198 // Create an autosave. 199 wp_create_post_autosave( 200 array( 201 'post_ID' => $page_id, 202 'post_content' => 'Autosave page content.', 203 'post_type' => 'page', 204 ) 205 ); 184 206 185 207 $tag_id = $this->factory->tag->create( … … 277 299 ), 278 300 array( 301 'route' => '/wp/v2/posts/' . $post_id . '/autosaves', 302 'name' => 'postAutosaves', 303 ), 304 array( 305 'route' => '/wp/v2/posts/' . $post_id . '/autosaves/' . $post_revision_id, 306 'name' => 'autosave', 307 ), 308 array( 279 309 'route' => '/wp/v2/pages', 280 310 'name' => 'PagesCollection', … … 291 321 'route' => '/wp/v2/pages/' . $page_id . '/revisions/' . $page_revision_id, 292 322 'name' => 'pageRevision', 323 ), 324 array( 325 'route' => '/wp/v2/pages/' . $page_id . '/autosaves', 326 'name' => 'pageAutosaves', 327 ), 328 array( 329 'route' => '/wp/v2/pages/' . $page_id . '/autosaves/' . $page_revision_id, 330 'name' => 'pageAutosave', 293 331 ), 294 332 array( -
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r43571 r44126 897 897 public function test_get_user_invalid_id() { 898 898 wp_set_current_user( self::$user ); 899 $request = new WP_REST_Request( 'GET', '/wp/v2/users/7777' ); 899 900 $request = new WP_REST_Request( 'GET', '/wp/v2/users/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); 900 901 $response = rest_get_server()->dispatch( $request ); 901 902 … … 2266 2267 wp_set_current_user( self::$user ); 2267 2268 2268 $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/ 7777');2269 $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); 2269 2270 $request['force'] = true; 2270 2271 $request->set_param( 'reassign', false ); … … 2318 2319 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) ); 2319 2320 $request['force'] = true; 2320 $request->set_param( 'reassign', 7777);2321 $request->set_param( 'reassign', REST_TESTS_IMPOSSIBLY_HIGH_NUMBER ); 2321 2322 $response = rest_get_server()->dispatch( $request ); 2322 2323 -
trunk/tests/qunit/fixtures/wp-api-generated.js
r44107 r44126 851 851 ] 852 852 }, 853 "/wp/v2/posts/(?P<parent>[\\d]+)/autosaves": { 854 "namespace": "wp/v2", 855 "methods": [ 856 "GET", 857 "POST" 858 ], 859 "endpoints": [ 860 { 861 "methods": [ 862 "GET" 863 ], 864 "args": { 865 "parent": { 866 "required": false, 867 "description": "The ID for the parent of the object.", 868 "type": "integer" 869 }, 870 "context": { 871 "required": false, 872 "default": "view", 873 "enum": [ 874 "view", 875 "embed", 876 "edit" 877 ], 878 "description": "Scope under which the request is made; determines fields present in response.", 879 "type": "string" 880 }, 881 "page": { 882 "required": false, 883 "default": 1, 884 "description": "Current page of the collection.", 885 "type": "integer" 886 }, 887 "per_page": { 888 "required": false, 889 "description": "Maximum number of items to be returned in result set.", 890 "type": "integer" 891 }, 892 "search": { 893 "required": false, 894 "description": "Limit results to those matching a string.", 895 "type": "string" 896 }, 897 "exclude": { 898 "required": false, 899 "default": [], 900 "description": "Ensure result set excludes specific IDs.", 901 "type": "array", 902 "items": { 903 "type": "integer" 904 } 905 }, 906 "include": { 907 "required": false, 908 "default": [], 909 "description": "Limit result set to specific IDs.", 910 "type": "array", 911 "items": { 912 "type": "integer" 913 } 914 }, 915 "offset": { 916 "required": false, 917 "description": "Offset the result set by a specific number of items.", 918 "type": "integer" 919 }, 920 "order": { 921 "required": false, 922 "default": "desc", 923 "enum": [ 924 "asc", 925 "desc" 926 ], 927 "description": "Order sort attribute ascending or descending.", 928 "type": "string" 929 }, 930 "orderby": { 931 "required": false, 932 "default": "date", 933 "enum": [ 934 "date", 935 "id", 936 "include", 937 "relevance", 938 "slug", 939 "include_slugs", 940 "title" 941 ], 942 "description": "Sort collection by object attribute.", 943 "type": "string" 944 } 945 } 946 }, 947 { 948 "methods": [ 949 "POST" 950 ], 951 "args": { 952 "parent": { 953 "required": false, 954 "description": "The ID for the parent of the object.", 955 "type": "integer" 956 }, 957 "author": { 958 "required": false, 959 "description": "The ID for the author of the object.", 960 "type": "integer" 961 }, 962 "date": { 963 "required": false, 964 "description": "The date the object was published, in the site's timezone.", 965 "type": "string" 966 }, 967 "date_gmt": { 968 "required": false, 969 "description": "The date the object was published, as GMT.", 970 "type": "string" 971 }, 972 "id": { 973 "required": false, 974 "description": "Unique identifier for the object.", 975 "type": "integer" 976 }, 977 "modified": { 978 "required": false, 979 "description": "The date the object was last modified, in the site's timezone.", 980 "type": "string" 981 }, 982 "modified_gmt": { 983 "required": false, 984 "description": "The date the object was last modified, as GMT.", 985 "type": "string" 986 }, 987 "slug": { 988 "required": false, 989 "description": "An alphanumeric identifier for the object unique to its type.", 990 "type": "string" 991 }, 992 "title": { 993 "required": false, 994 "description": "The title for the object.", 995 "type": "object" 996 }, 997 "content": { 998 "required": false, 999 "description": "The content for the object.", 1000 "type": "object" 1001 }, 1002 "excerpt": { 1003 "required": false, 1004 "description": "The excerpt for the object.", 1005 "type": "object" 1006 } 1007 } 1008 } 1009 ] 1010 }, 1011 "/wp/v2/posts/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)": { 1012 "namespace": "wp/v2", 1013 "methods": [ 1014 "GET" 1015 ], 1016 "endpoints": [ 1017 { 1018 "methods": [ 1019 "GET" 1020 ], 1021 "args": { 1022 "parent": { 1023 "required": false, 1024 "description": "The ID for the parent of the object.", 1025 "type": "integer" 1026 }, 1027 "id": { 1028 "required": false, 1029 "description": "The ID for the object.", 1030 "type": "integer" 1031 }, 1032 "context": { 1033 "required": false, 1034 "default": "view", 1035 "enum": [ 1036 "view", 1037 "embed", 1038 "edit" 1039 ], 1040 "description": "Scope under which the request is made; determines fields present in response.", 1041 "type": "string" 1042 } 1043 } 1044 } 1045 ] 1046 }, 853 1047 "/wp/v2/pages": { 854 1048 "namespace": "wp/v2", … … 1452 1646 "description": "Required to be true, as revisions do not support trashing.", 1453 1647 "type": "boolean" 1648 } 1649 } 1650 } 1651 ] 1652 }, 1653 "/wp/v2/pages/(?P<parent>[\\d]+)/autosaves": { 1654 "namespace": "wp/v2", 1655 "methods": [ 1656 "GET", 1657 "POST" 1658 ], 1659 "endpoints": [ 1660 { 1661 "methods": [ 1662 "GET" 1663 ], 1664 "args": { 1665 "parent": { 1666 "required": false, 1667 "description": "The ID for the parent of the object.", 1668 "type": "integer" 1669 }, 1670 "context": { 1671 "required": false, 1672 "default": "view", 1673 "enum": [ 1674 "view", 1675 "embed", 1676 "edit" 1677 ], 1678 "description": "Scope under which the request is made; determines fields present in response.", 1679 "type": "string" 1680 }, 1681 "page": { 1682 "required": false, 1683 "default": 1, 1684 "description": "Current page of the collection.", 1685 "type": "integer" 1686 }, 1687 "per_page": { 1688 "required": false, 1689 "description": "Maximum number of items to be returned in result set.", 1690 "type": "integer" 1691 }, 1692 "search": { 1693 "required": false, 1694 "description": "Limit results to those matching a string.", 1695 "type": "string" 1696 }, 1697 "exclude": { 1698 "required": false, 1699 "default": [], 1700 "description": "Ensure result set excludes specific IDs.", 1701 "type": "array", 1702 "items": { 1703 "type": "integer" 1704 } 1705 }, 1706 "include": { 1707 "required": false, 1708 "default": [], 1709 "description": "Limit result set to specific IDs.", 1710 "type": "array", 1711 "items": { 1712 "type": "integer" 1713 } 1714 }, 1715 "offset": { 1716 "required": false, 1717 "description": "Offset the result set by a specific number of items.", 1718 "type": "integer" 1719 }, 1720 "order": { 1721 "required": false, 1722 "default": "desc", 1723 "enum": [ 1724 "asc", 1725 "desc" 1726 ], 1727 "description": "Order sort attribute ascending or descending.", 1728 "type": "string" 1729 }, 1730 "orderby": { 1731 "required": false, 1732 "default": "date", 1733 "enum": [ 1734 "date", 1735 "id", 1736 "include", 1737 "relevance", 1738 "slug", 1739 "include_slugs", 1740 "title" 1741 ], 1742 "description": "Sort collection by object attribute.", 1743 "type": "string" 1744 } 1745 } 1746 }, 1747 { 1748 "methods": [ 1749 "POST" 1750 ], 1751 "args": { 1752 "parent": { 1753 "required": false, 1754 "description": "The ID for the parent of the object.", 1755 "type": "integer" 1756 }, 1757 "author": { 1758 "required": false, 1759 "description": "The ID for the author of the object.", 1760 "type": "integer" 1761 }, 1762 "date": { 1763 "required": false, 1764 "description": "The date the object was published, in the site's timezone.", 1765 "type": "string" 1766 }, 1767 "date_gmt": { 1768 "required": false, 1769 "description": "The date the object was published, as GMT.", 1770 "type": "string" 1771 }, 1772 "id": { 1773 "required": false, 1774 "description": "Unique identifier for the object.", 1775 "type": "integer" 1776 }, 1777 "modified": { 1778 "required": false, 1779 "description": "The date the object was last modified, in the site's timezone.", 1780 "type": "string" 1781 }, 1782 "modified_gmt": { 1783 "required": false, 1784 "description": "The date the object was last modified, as GMT.", 1785 "type": "string" 1786 }, 1787 "slug": { 1788 "required": false, 1789 "description": "An alphanumeric identifier for the object unique to its type.", 1790 "type": "string" 1791 }, 1792 "title": { 1793 "required": false, 1794 "description": "The title for the object.", 1795 "type": "object" 1796 }, 1797 "content": { 1798 "required": false, 1799 "description": "The content for the object.", 1800 "type": "object" 1801 }, 1802 "excerpt": { 1803 "required": false, 1804 "description": "The excerpt for the object.", 1805 "type": "object" 1806 } 1807 } 1808 } 1809 ] 1810 }, 1811 "/wp/v2/pages/(?P<parent>[\\d]+)/autosaves/(?P<id>[\\d]+)": { 1812 "namespace": "wp/v2", 1813 "methods": [ 1814 "GET" 1815 ], 1816 "endpoints": [ 1817 { 1818 "methods": [ 1819 "GET" 1820 ], 1821 "args": { 1822 "parent": { 1823 "required": false, 1824 "description": "The ID for the parent of the object.", 1825 "type": "integer" 1826 }, 1827 "id": { 1828 "required": false, 1829 "description": "The ID for the object.", 1830 "type": "integer" 1831 }, 1832 "context": { 1833 "required": false, 1834 "default": "view", 1835 "enum": [ 1836 "view", 1837 "embed", 1838 "edit" 1839 ], 1840 "description": "Scope under which the request is made; determines fields present in response.", 1841 "type": "string" 1454 1842 } 1455 1843 } … … 3851 4239 "version-history": [ 3852 4240 { 3853 "count": 1,4241 "count": 2, 3854 4242 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/4/revisions" 3855 4243 } … … 3943 4331 }, 3944 4332 "title": { 4333 "rendered": "" 4334 }, 4335 "content": { 4336 "rendered": "<p>Autosave post content.</p>\n" 4337 }, 4338 "excerpt": { 4339 "rendered": "" 4340 }, 4341 "_links": { 4342 "parent": [ 4343 { 4344 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/4" 4345 } 4346 ] 4347 } 4348 }, 4349 { 4350 "author": 359, 4351 "date": "2017-02-14T00:00:00", 4352 "date_gmt": "2017-02-14T00:00:00", 4353 "id": 36734, 4354 "modified": "2017-02-14T00:00:00", 4355 "modified_gmt": "2017-02-14T00:00:00", 4356 "parent": 36733, 4357 "slug": "36733-revision-v1", 4358 "guid": { 4359 "rendered": "http://example.org/?p=36734" 4360 }, 4361 "title": { 3945 4362 "rendered": "REST API Client Fixture: Post" 3946 4363 }, … … 3954 4371 "parent": [ 3955 4372 { 3956 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/ 4"4373 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/36733" 3957 4374 } 3958 4375 ] … … 3984 4401 }; 3985 4402 4403 mockedApiResponse.postAutosaves = [ 4404 { 4405 "author": 359, 4406 "date": "2017-02-14T00:00:00", 4407 "date_gmt": "2017-02-14T00:00:00", 4408 "id": 36735, 4409 "modified": "2017-02-14T00:00:00", 4410 "modified_gmt": "2017-02-14T00:00:00", 4411 "parent": 36733, 4412 "slug": "36733-autosave-v1", 4413 "guid": { 4414 "rendered": "http://example.org/?p=36735" 4415 }, 4416 "title": { 4417 "rendered": "" 4418 }, 4419 "content": { 4420 "rendered": "<p>Autosave post content.</p>\n" 4421 }, 4422 "excerpt": { 4423 "rendered": "" 4424 }, 4425 "_links": { 4426 "parent": [ 4427 { 4428 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/36733" 4429 } 4430 ] 4431 } 4432 } 4433 ]; 4434 4435 mockedApiResponse.autosave = { 4436 "author": 359, 4437 "date": "2017-02-14T00:00:00", 4438 "date_gmt": "2017-02-14T00:00:00", 4439 "id": 36735, 4440 "modified": "2017-02-14T00:00:00", 4441 "modified_gmt": "2017-02-14T00:00:00", 4442 "parent": 36733, 4443 "slug": "36733-autosave-v1", 4444 "guid": { 4445 "rendered": "http://example.org/?p=36735" 4446 }, 4447 "title": { 4448 "rendered": "" 4449 }, 4450 "content": { 4451 "rendered": "<p>Autosave post content.</p>\n" 4452 }, 4453 "excerpt": { 4454 "rendered": "" 4455 } 4456 }; 4457 3986 4458 mockedApiResponse.PagesCollection = [ 3987 4459 { … … 4043 4515 "version-history": [ 4044 4516 { 4045 "count": 1,4517 "count": 2, 4046 4518 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/6/revisions" 4047 4519 } … … 4119 4591 }, 4120 4592 "title": { 4593 "rendered": "" 4594 }, 4595 "content": { 4596 "rendered": "<p>Autosave page content.</p>\n" 4597 }, 4598 "excerpt": { 4599 "rendered": "" 4600 }, 4601 "_links": { 4602 "parent": [ 4603 { 4604 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/6" 4605 } 4606 ] 4607 } 4608 }, 4609 { 4610 "author": 359, 4611 "date": "2017-02-14T00:00:00", 4612 "date_gmt": "2017-02-14T00:00:00", 4613 "id": 36737, 4614 "modified": "2017-02-14T00:00:00", 4615 "modified_gmt": "2017-02-14T00:00:00", 4616 "parent": 36736, 4617 "slug": "36736-revision-v1", 4618 "guid": { 4619 "rendered": "http://example.org/?p=36737" 4620 }, 4621 "title": { 4121 4622 "rendered": "REST API Client Fixture: Page" 4122 4623 }, … … 4130 4631 "parent": [ 4131 4632 { 4132 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/ 6"4633 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/36736" 4133 4634 } 4134 4635 ] … … 4157 4658 "excerpt": { 4158 4659 "rendered": "<p>REST API Client Fixture: Page</p>\n" 4660 } 4661 }; 4662 4663 mockedApiResponse.pageAutosaves = [ 4664 { 4665 "author": 359, 4666 "date": "2017-02-14T00:00:00", 4667 "date_gmt": "2017-02-14T00:00:00", 4668 "id": 36738, 4669 "modified": "2017-02-14T00:00:00", 4670 "modified_gmt": "2017-02-14T00:00:00", 4671 "parent": 36736, 4672 "slug": "36736-autosave-v1", 4673 "guid": { 4674 "rendered": "http://example.org/?p=36738" 4675 }, 4676 "title": { 4677 "rendered": "" 4678 }, 4679 "content": { 4680 "rendered": "<p>Autosave page content.</p>\n" 4681 }, 4682 "excerpt": { 4683 "rendered": "" 4684 }, 4685 "_links": { 4686 "parent": [ 4687 { 4688 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/36736" 4689 } 4690 ] 4691 } 4692 } 4693 ]; 4694 4695 mockedApiResponse.pageAutosave = { 4696 "author": 359, 4697 "date": "2017-02-14T00:00:00", 4698 "date_gmt": "2017-02-14T00:00:00", 4699 "id": 36738, 4700 "modified": "2017-02-14T00:00:00", 4701 "modified_gmt": "2017-02-14T00:00:00", 4702 "parent": 36736, 4703 "slug": "36736-autosave-v1", 4704 "guid": { 4705 "rendered": "http://example.org/?p=36738" 4706 }, 4707 "title": { 4708 "rendered": "" 4709 }, 4710 "content": { 4711 "rendered": "<p>Autosave page content.</p>\n" 4712 }, 4713 "excerpt": { 4714 "rendered": "" 4159 4715 } 4160 4716 };
Note: See TracChangeset
for help on using the changeset viewer.