REST API: Skip generating the client test fixtures in PHP 5.2 and 5.3.

Follow-up to [40065] - `JSON_*` constants are differently unsupported in PHP 5.2 and 5.3, which caused other, more different failures.

Also bring back `JSON_UNESCAPED_SLASHES` because the generated output looks nicer this way.

Fixes #39264.


git-svn-id: https://develop.svn.wordpress.org/trunk@40066 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
James Nylen 2017-02-17 00:12:49 +00:00
parent 9d96b31b90
commit 900c67ed46
2 changed files with 223 additions and 217 deletions

View File

@ -275,15 +275,21 @@ class WP_Test_REST_Schema_Initialization extends WP_Test_REST_TestCase {
$this->assertTrue( ! empty( $data ), $route['name'] . ' route should return data.' );
$fixture = $this->normalize_fixture( $data, $route['name'] );
$mocked_responses .= "\nmockedApiResponse." . $route['name'] . ' = '
. json_encode( $fixture, JSON_PRETTY_PRINT )
. ";\n";
if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
$fixture = $this->normalize_fixture( $data, $route['name'] );
$mocked_responses .= "\nmockedApiResponse." . $route['name'] . ' = '
. json_encode( $fixture, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES )
. ";\n";
}
}
// Save the route object for QUnit tests.
$file = './tests/qunit/fixtures/wp-api-generated.js';
file_put_contents( $file, $mocked_responses );
if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
echo "Skipping generation of API client fixtures due to unsupported JSON_* constants.\n";
} else {
// Save the route object for QUnit tests.
$file = './tests/qunit/fixtures/wp-api-generated.js';
file_put_contents( $file, $mocked_responses );
}
// Clean up our test data.
wp_delete_post( $post_id, true );

File diff suppressed because it is too large Load Diff