Skip to content

Commit

Permalink
Allow installation of justinrainbow/json-schema:6.0 (#108)
Browse files Browse the repository at this point in the history
* Allow installation of justinrainbow/json-schema:6
* Test against lowest dependency versions
* Test against PHP 8.4
  • Loading branch information
W0rma authored Jul 31, 2024
1 parent 086762e commit 110fca6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:

strategy:
matrix:
php: [8.1, 8.2, 8.3]
php: [8.1, 8.2, 8.3, 8.4]
composer-options: ["", "--prefer-lowest"]

steps:
- name: Checkout code
Expand All @@ -27,7 +28,7 @@ jobs:
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-interaction --no-suggest
run: composer update --prefer-dist --no-progress --no-interaction --no-suggest ${{ matrix.composer-options }}

- name: Run test suite
run: php vendor/bin/codecept run
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ext-json": "*",
"codeception/codeception": "^5.0.8",
"codeception/lib-xml": "^1.0",
"justinrainbow/json-schema": "^5.2.9",
"justinrainbow/json-schema": "^5.2.9 || ^6",
"softcreatr/jsonpath": "^0.8 || ^0.9"
},
"require-dev": {
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/Codeception/Module/RestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Composer\InstalledVersions;
use Codeception\Configuration;
use Codeception\Exception\ModuleException;
use Codeception\Lib\Interfaces\API;
Expand Down Expand Up @@ -715,10 +716,16 @@ public function testRestExecute(string $configUrl, string $requestUrl, string $e

public static function schemaAndResponse(): array
{
if (version_compare(InstalledVersions::getVersion('justinrainbow/json-schema'), '6', '>=')) {
$errorInvalidBasicSchema = 'Must have a minimum value greater than or equal to 0';
} else {
$errorInvalidBasicSchema = 'Must have a minimum value of 0';
}

return [
//schema, responsefile, valid
['schemas/basic-schema.json', 'responses/valid-basic-schema.json', true, ""],
['schemas/basic-schema.json', 'responses/invalid-basic-schema.json', false, "Must have a minimum value of 0"],
['schemas/basic-schema.json', 'responses/invalid-basic-schema.json', false, $errorInvalidBasicSchema],
['schemas/complex-schema.json', 'responses/valid-complex-schema.json', true, ""],
['schemas/complex-schema.json', 'responses/invalid-complex-schema.json', false, "String value found, but a boolean is required"]
];
Expand Down

0 comments on commit 110fca6

Please sign in to comment.