Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 4 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,19 @@
# Tell Travis CI we're using PHP
language: php

# PHP version used in first build configuration.
php:
- "5.2"
- "5.3"
- "5.4"
- "5.5"

# WordPress version used in first build configuration.
env:
- WP_VERSION=master

# Next we define our matrix of additional build configurations to test against.
# The versions listed above will automatically create our first configuration,
# so it doesn't need to be re-defined below.

# WP_VERSION specifies the tag to use. The way these tests are configured to run
# requires at least WordPress 3.8. Specify "master" to test against SVN trunk.

# Note that Travis CI supports listing these above to automatically build a
# matrix of configurations, but we're being nice here by manually building a
# total of four configurations even though we're testing 4 versions of PHP
# along with 2 versions of WordPress (which would build 8 configs otherwise).
# This takes half as long to run while still providing adequate coverage.

matrix:
include:
- php: "5.3"
env: WP_VERSION=master
- php: "5.4"
env: WP_VERSION=3.8
- php: "5.2"
env: WP_VERSION=3.8

# Clones WordPress and configures our testing environment.
before_script:
- export PLUGIN_SLUG=$(basename $(pwd))
- git clone git://develop.git.wordpress.org/ /tmp/wordpress
- git clone --depth=1 git://develop.git.wordpress.org/ /tmp/wordpress
- mkdir "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
- cp -r . "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG/"
- cd /tmp/wordpress
- git checkout $WP_VERSION
- mysql -e "CREATE DATABASE wordpress_tests;" -uroot
- cp wp-tests-config-sample.php wp-tests-config.php
- sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,58 @@ working `PATH_INFO` on your server, but you don't need pretty permalinks
enabled.


## Quick Setup
Want to test out WP-API and work on it? Here's how you can set up your own
testing environment in a few easy steps:

1. Install [Vagrant](http://vagrantup.com/) and [VirtualBox](https://www.virtualbox.org/).
2. Clone [Chassis](https://github.com/sennza/Chassis):

```bash
git clone git@github.com:sennza/Chassis.git api-tester
```

3. Grab a copy of WP API:

```bash
mkdir -p content/plugins
git clone git@github.com:WP-API/WP-API.git content/plugins/json-rest-api
```

4. Start the virtual machine:

```bash
vagrant up
```

5. Browse to http://vagrant.local/wp/wp-admin/ and activate the WP API plugin
6. Browse to http://vagrant.local/wp-json.php/


### Testing
For testing, you'll need a little bit more:

1. Install PHPUnit:

```bash
wget https://phar.phpunit.de/phpunit.phar
```

2. Clone WordPress development (including tests):

```bash
git clone https://github.com/tierra/wordpress.git /tmp/wordpress
export WP_DEVELOP_DIR=/tmp/wordpress
```

3. Run the testing suite:

```bash
cd /vagrant/content/plugins/json-rest-api/tests
phpunit
```

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tierra Can you confirm this looks good for running the tests? :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though switch out https://github.com/tierra/wordpress.git with git://develop.git.wordpress.org.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you're using the Chassis bootstrap repo above, so I'm assuming that at this point, you already have a checkout of WP from it's git submodule. Want to use that instead of checking out another copy in /tmp?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point, you already have a checkout of WP from it's git submodule

Correct, but this is the core.svn mirror, not the develop.svn mirror, so the unit tests aren't included there. I assume we need those?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, correct, we do.



## Issue Tracking
All tickets for the project are being tracked on the [GSoC Trac][]. Make sure
you use the JSON REST API component.
Expand Down
22 changes: 0 additions & 22 deletions tests/test_json_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,6 @@
*/
class WP_Test_JSON_Plugin extends WP_UnitTestCase {

/**
* If these tests are being run on Travis CI, verify that the version of
* WordPress installed is the version that we requested.
*
* @requires PHP 5.3
*/
function test_wp_version() {
if ( !getenv( 'TRAVIS' ) )
$this->markTestSkipped( 'Travis CI was not detected.' );

$requested_version = getenv( 'WP_VERSION' ) . '-src';

// The "master" version requires special handling.
if ( $requested_version == 'master-src' ) {
$file = file_get_contents( 'https://raw.github.com/tierra/wordpress/master/src/wp-includes/version.php' );
preg_match( '#\$wp_version = \'([^\']+)\';#', $file, $matches );
$requested_version = $matches[1];
}

$this->assertEquals( get_bloginfo( 'version' ), $requested_version );
}

/**
* The plugin should be installed and activated.
*/
Expand Down