WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/17/2017 12:12:49 AM (2 years ago)
Author:
jnylen0
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-schema-setup.php

    r40065 r40066  
    276276            $this->assertTrue( ! empty( $data ), $route['name'] . ' route should return data.' );
    277277
    278             $fixture = $this->normalize_fixture( $data, $route['name'] );
    279             $mocked_responses .= "\nmockedApiResponse." . $route['name'] . ' = '
    280                 . json_encode( $fixture, JSON_PRETTY_PRINT )
    281                 . ";\n";
    282         }
    283 
    284         // Save the route object for QUnit tests.
    285         $file = './tests/qunit/fixtures/wp-api-generated.js';
    286         file_put_contents( $file, $mocked_responses );
     278            if ( version_compare( PHP_VERSION, '5.4', '>=' ) ) {
     279                $fixture = $this->normalize_fixture( $data, $route['name'] );
     280                $mocked_responses .= "\nmockedApiResponse." . $route['name'] . ' = '
     281                    . json_encode( $fixture, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES )
     282                    . ";\n";
     283            }
     284        }
     285
     286        if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
     287            echo "Skipping generation of API client fixtures due to unsupported JSON_* constants.\n";
     288        } else {
     289            // Save the route object for QUnit tests.
     290            $file = './tests/qunit/fixtures/wp-api-generated.js';
     291            file_put_contents( $file, $mocked_responses );
     292        }
    287293
    288294        // Clean up our test data.
Note: See TracChangeset for help on using the changeset viewer.