Changeset 43768
- Timestamp:
- 10/19/2018 01:48:42 PM (6 years ago)
- Location:
- branches/5.0
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/phpunit.xml.dist
r42666 r43768 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> -
branches/5.0/src/wp-includes/rest-api.php
r43766 r43768 194 194 $revisions_controller->register_routes(); 195 195 } 196 197 if ( 'attachment' !== $post_type->name ) { 198 $autosaves_controller = new WP_REST_Autosaves_Controller( $post_type->name ); 199 $autosaves_controller->register_routes(); 200 } 201 196 202 } 197 203 -
branches/5.0/src/wp-settings.php
r43752 r43768 230 230 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-post-statuses-controller.php' ); 231 231 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-revisions-controller.php' ); 232 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-autosaves-controller.php' ); 232 233 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-taxonomies-controller.php' ); 233 234 require( ABSPATH . WPINC . '/rest-api/endpoints/class-wp-rest-terms-controller.php' ); -
branches/5.0/tests/phpunit/multisite.xml
r41263 r43768 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 <exclude>tests/rest-api/rest-autosaves-controller.php</exclude> 18 19 <file phpVersion="5.3.0">tests/phpunit/tests/actions/closures.php</file> 19 20 <file phpVersion="5.3.0">tests/phpunit/tests/image/editor.php</file> 20 21 <file phpVersion="5.3.0">tests/phpunit/tests/image/editorGd.php</file> 21 22 <file phpVersion="5.3.0">tests/phpunit/tests/image/editorImagick.php</file> 23 </testsuite> 24 <!-- Sets the DOING_AUTOSAVE constant, so needs to be run last --> 25 <testsuite name="restapi-autosave"> 26 <file>tests/rest-api/rest-autosaves-controller.php</file> 22 27 </testsuite> 23 28 </testsuites> -
branches/5.0/tests/phpunit/tests/rest-api/rest-schema-setup.php
r43739 r43768 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]+)', … … 156 160 $post_revision_id = $post_revisions[ count( $post_revisions ) - 1 ]->ID; 157 161 162 // Create an autosave. 163 wp_create_post_autosave( 164 array( 165 'post_ID' => $post_id, 166 'post_content' => 'Autosave post content.', 167 'post_type' => 'post', 168 ) 169 ); 170 171 158 172 $page_id = $this->factory->post->create( array( 159 173 'post_type' => 'page', … … 173 187 $page_revision_id = $page_revisions[ count( $page_revisions ) - 1 ]->ID; 174 188 189 // Create an autosave. 190 wp_create_post_autosave( 191 array( 192 'post_ID' => $page_id, 193 'post_content' => 'Autosave page content.', 194 'post_type' => 'page', 195 ) 196 ); 197 175 198 $tag_id = $this->factory->tag->create( array( 176 199 'name' => 'REST API Client Fixture: Tag', … … 259 282 ), 260 283 array( 284 'route' => '/wp/v2/posts/' . $post_id . '/autosaves', 285 'name' => 'postAutosaves', 286 ), 287 array( 288 'route' => '/wp/v2/posts/' . $post_id . '/autosaves/' . $post_revision_id, 289 'name' => 'autosave', 290 ), 291 array( 261 292 'route' => '/wp/v2/pages', 262 293 'name' => 'PagesCollection', … … 273 304 'route' => '/wp/v2/pages/'. $page_id . '/revisions/' . $page_revision_id, 274 305 'name' => 'pageRevision', 306 ), 307 array( 308 'route' => '/wp/v2/pages/' . $page_id . '/autosaves', 309 'name' => 'pageAutosaves', 310 ), 311 array( 312 'route' => '/wp/v2/pages/' . $page_id . '/autosaves/' . $page_revision_id, 313 'name' => 'pageAutosave', 275 314 ), 276 315 array( -
branches/5.0/tests/qunit/fixtures/wp-api-generated.js
r43739 r43768 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 } … … 3843 4231 "version-history": [ 3844 4232 { 3845 "count": 1,4233 "count": 2, 3846 4234 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/4/revisions" 3847 4235 } … … 3935 4323 }, 3936 4324 "title": { 4325 "rendered": "" 4326 }, 4327 "content": { 4328 "rendered": "<p>Autosave post content.</p>\n" 4329 }, 4330 "excerpt": { 4331 "rendered": "" 4332 }, 4333 "_links": { 4334 "parent": [ 4335 { 4336 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/4" 4337 } 4338 ] 4339 } 4340 }, 4341 { 4342 "author": 389, 4343 "date": "2017-02-14T00:00:00", 4344 "date_gmt": "2017-02-14T00:00:00", 4345 "id": 36707, 4346 "modified": "2017-02-14T00:00:00", 4347 "modified_gmt": "2017-02-14T00:00:00", 4348 "parent": 36706, 4349 "slug": "36706-revision-v1", 4350 "guid": { 4351 "rendered": "http://example.org/?p=36707" 4352 }, 4353 "title": { 3937 4354 "rendered": "REST API Client Fixture: Post" 3938 4355 }, … … 3946 4363 "parent": [ 3947 4364 { 3948 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/ 4"4365 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/36706" 3949 4366 } 3950 4367 ] … … 3976 4393 }; 3977 4394 4395 mockedApiResponse.postAutosaves = [ 4396 { 4397 "author": 389, 4398 "date": "2017-02-14T00:00:00", 4399 "date_gmt": "2017-02-14T00:00:00", 4400 "id": 36708, 4401 "modified": "2017-02-14T00:00:00", 4402 "modified_gmt": "2017-02-14T00:00:00", 4403 "parent": 36706, 4404 "slug": "36706-autosave-v1", 4405 "guid": { 4406 "rendered": "http://example.org/?p=36708" 4407 }, 4408 "title": { 4409 "rendered": "" 4410 }, 4411 "content": { 4412 "rendered": "<p>Autosave post content.</p>\n" 4413 }, 4414 "excerpt": { 4415 "rendered": "" 4416 }, 4417 "_links": { 4418 "parent": [ 4419 { 4420 "href": "http://example.org/index.php?rest_route=/wp/v2/posts/36706" 4421 } 4422 ] 4423 } 4424 } 4425 ]; 4426 4427 mockedApiResponse.autosave = { 4428 "author": 389, 4429 "date": "2017-02-14T00:00:00", 4430 "date_gmt": "2017-02-14T00:00:00", 4431 "id": 36708, 4432 "modified": "2017-02-14T00:00:00", 4433 "modified_gmt": "2017-02-14T00:00:00", 4434 "parent": 36706, 4435 "slug": "36706-autosave-v1", 4436 "guid": { 4437 "rendered": "http://example.org/?p=36708" 4438 }, 4439 "title": { 4440 "rendered": "" 4441 }, 4442 "content": { 4443 "rendered": "<p>Autosave post content.</p>\n" 4444 }, 4445 "excerpt": { 4446 "rendered": "" 4447 } 4448 }; 4449 3978 4450 mockedApiResponse.PagesCollection = [ 3979 4451 { … … 4035 4507 "version-history": [ 4036 4508 { 4037 "count": 1,4509 "count": 2, 4038 4510 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/6/revisions" 4039 4511 } … … 4111 4583 }, 4112 4584 "title": { 4585 "rendered": "" 4586 }, 4587 "content": { 4588 "rendered": "<p>Autosave page content.</p>\n" 4589 }, 4590 "excerpt": { 4591 "rendered": "" 4592 }, 4593 "_links": { 4594 "parent": [ 4595 { 4596 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/6" 4597 } 4598 ] 4599 } 4600 }, 4601 { 4602 "author": 389, 4603 "date": "2017-02-14T00:00:00", 4604 "date_gmt": "2017-02-14T00:00:00", 4605 "id": 36710, 4606 "modified": "2017-02-14T00:00:00", 4607 "modified_gmt": "2017-02-14T00:00:00", 4608 "parent": 36709, 4609 "slug": "36709-revision-v1", 4610 "guid": { 4611 "rendered": "http://example.org/?p=36710" 4612 }, 4613 "title": { 4113 4614 "rendered": "REST API Client Fixture: Page" 4114 4615 }, … … 4122 4623 "parent": [ 4123 4624 { 4124 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/ 6"4625 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/36709" 4125 4626 } 4126 4627 ] … … 4149 4650 "excerpt": { 4150 4651 "rendered": "<p>REST API Client Fixture: Page</p>\n" 4652 } 4653 }; 4654 4655 mockedApiResponse.pageAutosaves = [ 4656 { 4657 "author": 389, 4658 "date": "2017-02-14T00:00:00", 4659 "date_gmt": "2017-02-14T00:00:00", 4660 "id": 36711, 4661 "modified": "2017-02-14T00:00:00", 4662 "modified_gmt": "2017-02-14T00:00:00", 4663 "parent": 36709, 4664 "slug": "36709-autosave-v1", 4665 "guid": { 4666 "rendered": "http://example.org/?p=36711" 4667 }, 4668 "title": { 4669 "rendered": "" 4670 }, 4671 "content": { 4672 "rendered": "<p>Autosave page content.</p>\n" 4673 }, 4674 "excerpt": { 4675 "rendered": "" 4676 }, 4677 "_links": { 4678 "parent": [ 4679 { 4680 "href": "http://example.org/index.php?rest_route=/wp/v2/pages/36709" 4681 } 4682 ] 4683 } 4684 } 4685 ]; 4686 4687 mockedApiResponse.pageAutosave = { 4688 "author": 389, 4689 "date": "2017-02-14T00:00:00", 4690 "date_gmt": "2017-02-14T00:00:00", 4691 "id": 36711, 4692 "modified": "2017-02-14T00:00:00", 4693 "modified_gmt": "2017-02-14T00:00:00", 4694 "parent": 36709, 4695 "slug": "36709-autosave-v1", 4696 "guid": { 4697 "rendered": "http://example.org/?p=36711" 4698 }, 4699 "title": { 4700 "rendered": "" 4701 }, 4702 "content": { 4703 "rendered": "<p>Autosave page content.</p>\n" 4704 }, 4705 "excerpt": { 4706 "rendered": "" 4151 4707 } 4152 4708 };
Note: See TracChangeset
for help on using the changeset viewer.