Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

Commit ea14da4

Browse files
committed
Update testing instructions based on WP trunk (WIP)
1 parent 3900988 commit ea14da4

1 file changed

Lines changed: 82 additions & 7 deletions

File tree

‎README.md‎

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,90 @@ There's no fixed timeline for integration into core at this time, but getting
4444
closer!
4545

4646

47-
## Installation
47+
## Quick Setup
4848

49-
Drop this directory into your plugins folder and activate it. You need to be
50-
using pretty permalinks to use the plugin, as it uses custom rewrite rules to
51-
power the API.
49+
Want to test out the WP REST API? The easiest way is just to install a
50+
recent development version of WordPress (for starters, try
51+
[4.7 beta 4](https://wordpress.org/news/2016/11/wordpress-4-7-beta-4/).
5252

53-
Also, be sure to use the Subversion `trunk` branch of WordPress Core as there
54-
are potentially recent commits to Core that the REST API relies on. See the
55-
[WordPress.org website](https://wordpress.org/download/svn/) for simple instructions.
53+
### Testing
54+
55+
You can also set up a development environment to work on the API code.
56+
57+
See the
58+
[instructions for running the WordPress PHPUnit test suite](https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/)
59+
to get started.
60+
61+
Here is another way to set up a development environment using a virtual
62+
machine:
63+
64+
1. Install [Vagrant](http://vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/).
65+
2. Clone [Chassis](https://github.com/Chassis/Chassis):
66+
67+
```bash
68+
git clone --recursive git@github.com:Chassis/Chassis.git api-tester
69+
```
70+
71+
3. Clone the [Tester extension](https://github.com/Chassis/Tester) for Chassis:
72+
73+
```bash
74+
# From your base directory, api-tester if following the steps from before
75+
git clone --recursive https://github.com/Chassis/Tester.git extensions/tester
76+
```
77+
78+
4. Update the `wpdevel` submodule in Chassis to latest on master from [WordPress Git Mirror](https://make.wordpress.org/core/2014/01/15/git-mirrors-for-wordpress/):
79+
80+
```bash
81+
# From your base directory, api-tester if following the steps from before
82+
cd extensions/tester/wpdevel
83+
git checkout master
84+
git pull
85+
cd ../../..
86+
```
87+
88+
5. Start the virtual machine:
89+
90+
```bash
91+
vagrant up
92+
```
93+
94+
6. Set the permalink structure to something other than the default, in order to
95+
enable the http://vagrant.local/wp-json/ endpoint URL (if you skip this
96+
step, it can be accessed at http://vagrant.local/?json_route=/):
97+
98+
```bash
99+
vagrant ssh -c "cd /vagrant && wp rewrite structure '/%postname%/'"
100+
```
101+
102+
7. Log in to the virtual machine and run the testing suite:
103+
104+
```bash
105+
vagrant ssh
106+
cd /vagrant/extensions/tester/wpdevel/
107+
phpunit --filter REST
108+
```
109+
110+
**TODO: This is broken: PHP Fatal error: Class 'DOMDocument' not found ...**
111+
112+
**TODO: How to keep `wpdevel/src/` and `/vagrant/wp/` in sync?**
113+
114+
You can also execute the tests in the context of the VM without SSHing
115+
into the virtual machine (this is equivalent to the above):
116+
117+
```bash
118+
vagrant ssh -c 'cd /vagrant/extensions/tester/wpdevel/ && phpunit --filter REST'
119+
```
120+
121+
You're done! You should now have a WordPress site available at
122+
http://vagrant.local; you can access the API via http://vagrant.local/wp-json/
123+
124+
To access the admin interface, visit http://vagrant.local/wp/wp-admin and log
125+
in with the credentials below:
126+
127+
```
128+
Username: admin
129+
Password: password
130+
```
56131

57132
## Issue Tracking
58133

0 commit comments

Comments
 (0)