From e424065e83098a53b928fc410e27882b4e8f48ca Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 16 Nov 2020 17:44:13 +0100 Subject: [PATCH 1/8] Change the PostProcessorInterface to an abstract class PostProcessor to implement pre/post execution hooks for post processors --- docs/source/generator/postProcessor.rst | 8 +++-- src/Model/RenderJob.php | 4 +-- src/ModelGenerator.php | 8 ++--- ...itionalPropertiesAccessorPostProcessor.php | 2 +- .../CompositionValidationPostProcessor.php | 4 +-- .../PostProcessor/PopulatePostProcessor.php | 2 +- .../PostProcessor/PostProcessor.php | 33 +++++++++++++++++++ .../PostProcessor/PostProcessorInterface.php | 19 ----------- .../SerializationPostProcessor.php | 2 +- src/SchemaProcessor/RenderQueue.php | 12 +++++-- tests/Basic/BasicSchemaGenerationTest.php | 4 +-- tests/Basic/SchemaHookTest.php | 4 +-- ...nalPropertiesAccessorPostProcessorTest.php | 4 +-- .../PopulatePostProcessorTest.php | 6 ++-- 14 files changed, 68 insertions(+), 44 deletions(-) create mode 100644 src/SchemaProcessor/PostProcessor/PostProcessor.php delete mode 100644 src/SchemaProcessor/PostProcessor/PostProcessorInterface.php diff --git a/docs/source/generator/postProcessor.rst b/docs/source/generator/postProcessor.rst index 0244708..14ba4a3 100644 --- a/docs/source/generator/postProcessor.rst +++ b/docs/source/generator/postProcessor.rst @@ -144,7 +144,7 @@ By default additional properties are not included in serialized models. If the * Custom Post Processors ---------------------- -You can implement custom post processors to accomplish your tasks. Each post processor must implement the **PHPModelGenerator\\SchemaProcessor\\PostProcessor\\PostProcessorInterface**. If you have implemented a post processor add the post processor to your `ModelGenerator` and the post processor will be executed for each class. +You can implement custom post processors to accomplish your tasks. Each post processor must extend the class **PHPModelGenerator\\SchemaProcessor\\PostProcessor\\PostProcessor**. If you have implemented a post processor add the post processor to your `ModelGenerator` and the post processor will be executed for each class. A custom post processor which adds a custom trait to the generated model (eg. a trait adding methods for an active record pattern implementation) may look like: @@ -153,9 +153,9 @@ A custom post processor which adds a custom trait to the generated model (eg. a namespace MyApp\Model\Generator\PostProcessor; use MyApp\Model\ActiveRecordTrait; - use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; + use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; - class ActiveRecordPostProcessor implements PostProcessorInterface + class ActiveRecordPostProcessor extends PostProcessor { public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void { @@ -184,3 +184,5 @@ What can you do inside your custom post processor? If a setter for a property is called with the same value which is already stored internally (consequently no update of the property is required), the setters will return directly and as a result of that the setter hooks will not be executed. This behaviour also applies also to properties changed via the *populate* method added by the `PopulatePostProcessor <#populatepostprocessor>`__ and the *setAdditionalProperty* method added by the `AdditionalPropertiesAccessorPostProcessor <#additionalpropertiesaccessorpostprocessor>`__ + +To execute code before/after the processing of the schemas override the methods **preProcess** and **postProcess** inside your custom post processor. \ No newline at end of file diff --git a/src/Model/RenderJob.php b/src/Model/RenderJob.php index 1084415..3b9effe 100644 --- a/src/Model/RenderJob.php +++ b/src/Model/RenderJob.php @@ -11,7 +11,7 @@ use PHPModelGenerator\Exception\ValidationException; use PHPModelGenerator\Model\Validator\AbstractComposedPropertyValidator; use PHPModelGenerator\SchemaProcessor\Hook\SchemaHookResolver; -use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; +use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; use PHPModelGenerator\Utils\RenderHelper; /** @@ -51,7 +51,7 @@ public function __construct( } /** - * @param PostProcessorInterface[] $postProcessors + * @param PostProcessor[] $postProcessors * @param GeneratorConfiguration $generatorConfiguration */ public function postProcess(array $postProcessors, GeneratorConfiguration $generatorConfiguration) diff --git a/src/ModelGenerator.php b/src/ModelGenerator.php index 2dd43d3..a5eb642 100644 --- a/src/ModelGenerator.php +++ b/src/ModelGenerator.php @@ -10,7 +10,7 @@ use PHPModelGenerator\Exception\SchemaException; use PHPModelGenerator\Model\GeneratorConfiguration; use PHPModelGenerator\SchemaProcessor\PostProcessor\Internal\CompositionValidationPostProcessor; -use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; +use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; use PHPModelGenerator\SchemaProcessor\PostProcessor\SerializationPostProcessor; use PHPModelGenerator\SchemaProcessor\RenderQueue; use PHPModelGenerator\SchemaProcessor\SchemaProcessor; @@ -27,7 +27,7 @@ class ModelGenerator { /** @var GeneratorConfiguration */ protected $generatorConfiguration; - /** @var PostProcessorInterface[] */ + /** @var PostProcessor[] */ protected $postProcessors = []; /** @@ -48,11 +48,11 @@ public function __construct(GeneratorConfiguration $generatorConfiguration = nul } /** - * @param PostProcessorInterface $postProcessor + * @param PostProcessor $postProcessor * * @return $this */ - public function addPostProcessor(PostProcessorInterface $postProcessor): self + public function addPostProcessor(PostProcessor $postProcessor): self { $this->postProcessors[] = $postProcessor; diff --git a/src/SchemaProcessor/PostProcessor/AdditionalPropertiesAccessorPostProcessor.php b/src/SchemaProcessor/PostProcessor/AdditionalPropertiesAccessorPostProcessor.php index 78eaa43..ca1ddf2 100644 --- a/src/SchemaProcessor/PostProcessor/AdditionalPropertiesAccessorPostProcessor.php +++ b/src/SchemaProcessor/PostProcessor/AdditionalPropertiesAccessorPostProcessor.php @@ -25,7 +25,7 @@ * * @package PHPModelGenerator\SchemaProcessor\PostProcessor */ -class AdditionalPropertiesAccessorPostProcessor implements PostProcessorInterface +class AdditionalPropertiesAccessorPostProcessor extends PostProcessor { /** @var bool */ private $addForModelsWithoutAdditionalPropertiesDefinition; diff --git a/src/SchemaProcessor/PostProcessor/Internal/CompositionValidationPostProcessor.php b/src/SchemaProcessor/PostProcessor/Internal/CompositionValidationPostProcessor.php index c086410..a03ac81 100644 --- a/src/SchemaProcessor/PostProcessor/Internal/CompositionValidationPostProcessor.php +++ b/src/SchemaProcessor/PostProcessor/Internal/CompositionValidationPostProcessor.php @@ -11,7 +11,7 @@ use PHPModelGenerator\Model\SchemaDefinition\JsonSchema; use PHPModelGenerator\Model\Validator\AbstractComposedPropertyValidator; use PHPModelGenerator\SchemaProcessor\Hook\SetterBeforeValidationHookInterface; -use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; +use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; use PHPModelGenerator\SchemaProcessor\PostProcessor\RenderedMethod; use PHPModelGenerator\Utils\RenderHelper; @@ -25,7 +25,7 @@ * * @package PHPModelGenerator\SchemaProcessor\PostProcessor\Internal */ -class CompositionValidationPostProcessor implements PostProcessorInterface +class CompositionValidationPostProcessor extends PostProcessor { /** * @param Schema $schema diff --git a/src/SchemaProcessor/PostProcessor/PopulatePostProcessor.php b/src/SchemaProcessor/PostProcessor/PopulatePostProcessor.php index 2a23e82..8d0ec2d 100644 --- a/src/SchemaProcessor/PostProcessor/PopulatePostProcessor.php +++ b/src/SchemaProcessor/PostProcessor/PopulatePostProcessor.php @@ -13,7 +13,7 @@ * * @package PHPModelGenerator\SchemaProcessor\PostProcessor */ -class PopulatePostProcessor implements PostProcessorInterface +class PopulatePostProcessor extends PostProcessor { public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void { diff --git a/src/SchemaProcessor/PostProcessor/PostProcessor.php b/src/SchemaProcessor/PostProcessor/PostProcessor.php new file mode 100644 index 0000000..37baeae --- /dev/null +++ b/src/SchemaProcessor/PostProcessor/PostProcessor.php @@ -0,0 +1,33 @@ +preProcess(); + } + foreach ($this->jobs as $job) { $job->postProcess($postProcessors, $generatorConfiguration); $job->render($destination, $generatorConfiguration); } + foreach ($postProcessors as $postProcessor) { + $postProcessor->postProcess(); + } + $this->jobs = []; } } \ No newline at end of file diff --git a/tests/Basic/BasicSchemaGenerationTest.php b/tests/Basic/BasicSchemaGenerationTest.php index 370fbfc..a5347b2 100644 --- a/tests/Basic/BasicSchemaGenerationTest.php +++ b/tests/Basic/BasicSchemaGenerationTest.php @@ -13,7 +13,7 @@ use PHPModelGenerator\Model\Schema; use PHPModelGenerator\ModelGenerator; use PHPModelGenerator\SchemaProcessor\Hook\SetterBeforeValidationHookInterface; -use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; +use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; use PHPModelGenerator\Tests\AbstractPHPModelGeneratorTest; /** @@ -66,7 +66,7 @@ public function testGetterAndSetterAreGeneratedForMutableObjects(bool $implicitN public function testSetterLogicIsNotExecutedWhenValueIsIdentical(): void { $this->modifyModelGenerator = function (ModelGenerator $modelGenerator): void { - $modelGenerator->addPostProcessor(new class () implements PostProcessorInterface { + $modelGenerator->addPostProcessor(new class () extends PostProcessor { public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void { $schema->addSchemaHook(new class () implements SetterBeforeValidationHookInterface { diff --git a/tests/Basic/SchemaHookTest.php b/tests/Basic/SchemaHookTest.php index be72f16..475fdce 100644 --- a/tests/Basic/SchemaHookTest.php +++ b/tests/Basic/SchemaHookTest.php @@ -15,7 +15,7 @@ use PHPModelGenerator\SchemaProcessor\Hook\SchemaHookInterface; use PHPModelGenerator\SchemaProcessor\Hook\SetterAfterValidationHookInterface; use PHPModelGenerator\SchemaProcessor\Hook\SetterBeforeValidationHookInterface; -use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; +use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; use PHPModelGenerator\Tests\AbstractPHPModelGeneratorTest; /** @@ -184,7 +184,7 @@ public function setterAfterValidationHookDataProvider(): array protected function addSchemaHook(SchemaHookInterface $schemaHook): void { $this->modifyModelGenerator = function (ModelGenerator $modelGenerator) use ($schemaHook): void { - $modelGenerator->addPostProcessor(new class ($schemaHook) implements PostProcessorInterface { + $modelGenerator->addPostProcessor(new class ($schemaHook) extends PostProcessor { private $schemaHook; public function __construct(SchemaHookInterface $schemaHook) diff --git a/tests/PostProcessor/AdditionalPropertiesAccessorPostProcessorTest.php b/tests/PostProcessor/AdditionalPropertiesAccessorPostProcessorTest.php index 9aabf2f..2c6ff16 100644 --- a/tests/PostProcessor/AdditionalPropertiesAccessorPostProcessorTest.php +++ b/tests/PostProcessor/AdditionalPropertiesAccessorPostProcessorTest.php @@ -16,7 +16,7 @@ use PHPModelGenerator\ModelGenerator; use PHPModelGenerator\SchemaProcessor\Hook\SetterBeforeValidationHookInterface; use PHPModelGenerator\SchemaProcessor\PostProcessor\AdditionalPropertiesAccessorPostProcessor; -use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; +use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; use PHPModelGenerator\Tests\AbstractPHPModelGeneratorTest; /** @@ -268,7 +268,7 @@ public function testSetterSchemaHooksAreResolvedInSetAdditionalProperties(): voi $this->modifyModelGenerator = function (ModelGenerator $modelGenerator): void { $modelGenerator ->addPostProcessor(new AdditionalPropertiesAccessorPostProcessor()) - ->addPostProcessor(new class () implements PostProcessorInterface { + ->addPostProcessor(new class () extends PostProcessor { public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void { $schema->addSchemaHook(new class () implements SetterBeforeValidationHookInterface { diff --git a/tests/PostProcessor/PopulatePostProcessorTest.php b/tests/PostProcessor/PopulatePostProcessorTest.php index 5494135..10b28ba 100644 --- a/tests/PostProcessor/PopulatePostProcessorTest.php +++ b/tests/PostProcessor/PopulatePostProcessorTest.php @@ -17,7 +17,7 @@ use PHPModelGenerator\SchemaProcessor\Hook\SetterAfterValidationHookInterface; use PHPModelGenerator\SchemaProcessor\Hook\SetterBeforeValidationHookInterface; use PHPModelGenerator\SchemaProcessor\PostProcessor\PopulatePostProcessor; -use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessorInterface; +use PHPModelGenerator\SchemaProcessor\PostProcessor\PostProcessor; use PHPModelGenerator\Tests\AbstractPHPModelGeneratorTest; class PopulatePostProcessorTest extends AbstractPHPModelGeneratorTest @@ -205,7 +205,7 @@ public function testSetterBeforeValidationHookInsidePopulateIsResolved(): void { $this->modifyModelGenerator = function (ModelGenerator $modelGenerator): void { $modelGenerator->addPostProcessor(new PopulatePostProcessor()); - $modelGenerator->addPostProcessor(new class () implements PostProcessorInterface { + $modelGenerator->addPostProcessor(new class () extends PostProcessor { public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void { $schema->addSchemaHook(new class () implements SetterBeforeValidationHookInterface { @@ -249,7 +249,7 @@ public function testSetterAfterValidationHookInsidePopulateIsResolved( { $this->modifyModelGenerator = function (ModelGenerator $modelGenerator): void { $modelGenerator->addPostProcessor(new PopulatePostProcessor()); - $modelGenerator->addPostProcessor(new class () implements PostProcessorInterface { + $modelGenerator->addPostProcessor(new class () extends PostProcessor { public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void { $schema->addSchemaHook(new class () implements SetterAfterValidationHookInterface { From 3c8a2f6d94351ac1ef577d501ae5ddfa11709770 Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 30 Nov 2020 15:07:56 +0100 Subject: [PATCH 2/8] Add test suite wrapper around json-schema/json-schema-test-suite --- .travis.yml | 14 ++- composer.json | 17 ++- phpunit.xml | 14 ++- .../JsonSchemaTestSuiteTest.php | 104 ++++++++++++++++++ .../ObjectTemplate.json | 6 + 5 files changed, 149 insertions(+), 6 deletions(-) create mode 100644 tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php create mode 100644 tests/Schema/JsonSchemaTestSuiteTest/ObjectTemplate.json diff --git a/.travis.yml b/.travis.yml index aa7e57f..5f2c2fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,15 @@ language: php sudo: false env: + - TEST_SUITE="PHPModelGenerator" FILTER="." + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3/optional]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4/optional]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6/optional]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" global: - CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 @@ -28,9 +37,12 @@ before_script: - mkdir -p build/logs script: - - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testdox + - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testdox --testsuite=$TEST_SUITE --filter="$FILTER" + allow_failures: + - env: SECRET_VAR1=SECRET1 SECRET_VAR2=SECRET2 after_script: + - if "PHPModelGenerator" = env(TEST_SUITE) - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT - travis_retry php coveralls.phar -v - vendor/bin/test-reporter diff --git a/composer.json b/composer.json index 4dd7229..22fed22 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "ext-mbstring": "*" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.4" + "phpunit/phpunit": "^8.5 || ^9.4", + "json-schema/json-schema-test-suite": "2.0.0" }, "suggest": { "symplify/easy-coding-standard": "Allows pretty printing of the generated code" @@ -29,6 +30,20 @@ "PHPModelGenerator\\": "src" } }, + "repositories": [ + { + "type": "package", + "package": { + "name": "json-schema/json-schema-test-suite", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/json-schema/JSON-Schema-Test-Suite", + "reference": "2.0.0" + } + } + } + ], "autoload-dev": { "psr-4": { "PHPModelGenerator\\Tests\\": "tests", diff --git a/phpunit.xml b/phpunit.xml index 9418892..53e4386 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -16,8 +16,14 @@ src - - tests - tests/manual - + + + tests + tests/manual + tests/JsonSchemaTestSuite + + + tests/JsonSchemaTestSuite + + diff --git a/tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php b/tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php new file mode 100644 index 0000000..fd5135f --- /dev/null +++ b/tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php @@ -0,0 +1,104 @@ +generateClassFromFileTemplate('ObjectTemplate.json', [$schema], null, false, false); + + if (!$valid) { + $this->expectException(ValidationException::class); + } else { + $this->expectNotToPerformAssertions(); + } + + new $className($data); + + $this->fail(); + } + + public function draftDataProvider(): array + { + $drafts = [ + 'draft3', + 'draft3/optional', + 'draft4', + 'draft4/optional', + 'draft6', + 'draft6/optional', + 'draft7', + 'draft7/optional', + ]; + + $tests = []; + + foreach ($this->getFilesForDraft('draft7') as $key => $path) { + foreach ($this->setUpDataProviderFromSchemaTestSuiteFile($path) as $testSuiteKey => $test) { + $tests["Draft suite[$key] - $testSuiteKey"] = $test; + } + } + + return $tests; + } + + public function getFilesForDraft(string $draft): array + { + $files = []; + + foreach ( + new DirectoryIterator(__DIR__ . '/../../vendor/json-schema/json-schema-test-suite/tests/' . $draft) + as + $item + ) { + if ($item->isFile()) { + $files[$item->getBasename()] = $item->getRealPath(); + } + } + + return $files; + } + + public function setUpDataProviderFromSchemaTestSuiteFile(string $file): array + { + $testFile = json_decode(file_get_contents($file), true); + + $tests = []; + + foreach ($testFile as $test) { + foreach ($test['tests'] as $dataProvider) { + $tests["{$test['description']}: {$dataProvider['description']}"] = [ + 'schema' => json_encode($test['schema']), + 'valid' => $dataProvider['valid'], + 'data' => ['property' => $dataProvider['data']], + ]; + } + } + + return $tests; + } +} diff --git a/tests/Schema/JsonSchemaTestSuiteTest/ObjectTemplate.json b/tests/Schema/JsonSchemaTestSuiteTest/ObjectTemplate.json new file mode 100644 index 0000000..7cb060c --- /dev/null +++ b/tests/Schema/JsonSchemaTestSuiteTest/ObjectTemplate.json @@ -0,0 +1,6 @@ +{ + "type": "object", + "properties": { + "property": %s + } +} \ No newline at end of file From abced5d97068cca04be02e1d56ce8acbc4a68b0b Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 30 Nov 2020 15:28:57 +0100 Subject: [PATCH 3/8] CI --- .travis.yml | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5f2c2fb..72a0143 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,18 +2,18 @@ language: php sudo: false -env: - - TEST_SUITE="PHPModelGenerator" FILTER="." - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3/optional]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4/optional]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6/optional]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" - global: - - CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 +jobs: + include: + - env: TEST_SUITE="PHPModelGenerator" FILTER="." CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 + allow_failures: + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3/optional]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4/optional]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6/optional]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" php: - 7.2 @@ -38,11 +38,8 @@ before_script: script: - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testdox --testsuite=$TEST_SUITE --filter="$FILTER" - allow_failures: - - env: SECRET_VAR1=SECRET1 SECRET_VAR2=SECRET2 after_script: - - if "PHPModelGenerator" = env(TEST_SUITE) - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT - travis_retry php coveralls.phar -v - vendor/bin/test-reporter From f0c4c30ec930c0e0ac86c8e4733c1a1be9acc76f Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 30 Nov 2020 15:34:13 +0100 Subject: [PATCH 4/8] CI --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.travis.yml b/.travis.yml index 72a0143..193c9ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,17 @@ language: php sudo: false +env: + - TEST_SUITE="PHPModelGenerator" FILTER="." CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3/optional]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4/optional]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6/optional]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" + jobs: include: - env: TEST_SUITE="PHPModelGenerator" FILTER="." CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 From 879f90ad33aa6c8d26a137d102faa10d7f0c4e23 Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 30 Nov 2020 15:41:30 +0100 Subject: [PATCH 5/8] CI --- .travis.yml | 2 +- tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 193c9ad..df2179e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ before_script: - mkdir -p build/logs script: - - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testdox --testsuite=$TEST_SUITE --filter="$FILTER" + - ./vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testdox --testsuite="$TEST_SUITE" --filter="$FILTER" after_script: - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT diff --git a/tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php b/tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php index fd5135f..bbfdef3 100644 --- a/tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php +++ b/tests/JsonSchemaTestSuite/JsonSchemaTestSuiteTest.php @@ -57,9 +57,11 @@ public function draftDataProvider(): array $tests = []; - foreach ($this->getFilesForDraft('draft7') as $key => $path) { - foreach ($this->setUpDataProviderFromSchemaTestSuiteFile($path) as $testSuiteKey => $test) { - $tests["Draft suite[$key] - $testSuiteKey"] = $test; + foreach ($drafts as $draft) { + foreach ($this->getFilesForDraft($draft) as $key => $path) { + foreach ($this->setUpDataProviderFromSchemaTestSuiteFile($path) as $testSuiteKey => $test) { + $tests["Draft suite[$draft] $key - $testSuiteKey"] = $test; + } } } From 29eeae09d9e247f8b8e7a96c3140e4d7a8dd74ff Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 30 Nov 2020 15:55:42 +0100 Subject: [PATCH 6/8] CI --- .travis.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index df2179e..d759e5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,17 +14,15 @@ env: - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" jobs: - include: - - env: TEST_SUITE="PHPModelGenerator" FILTER="." CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 allow_failures: - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3]" - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3/optional]" - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4]" - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4/optional]" - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6]" - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6/optional]" - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7]" - - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3\]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3/optional\]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft4\]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft4/optional\]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft6\]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft6/optional\]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft7\]" + - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft7/optional\]" php: - 7.2 From efd66346567836f0c921360d359ecb72d6eef6ca Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 30 Nov 2020 15:57:23 +0100 Subject: [PATCH 7/8] CI --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d759e5a..bea022d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,8 @@ env: - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" jobs: + include: + - env: TEST_SUITE="PHPModelGenerator" FILTER="." CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 allow_failures: - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3\]" - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3/optional\]" From 60015fb20033aaded95634278f76f28c5aeab8c9 Mon Sep 17 00:00:00 2001 From: Enno Woortmann Date: Mon, 30 Nov 2020 15:59:58 +0100 Subject: [PATCH 8/8] CI --- .travis.yml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index bea022d..1b32d89 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,18 +4,16 @@ sudo: false env: - TEST_SUITE="PHPModelGenerator" FILTER="." CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft3/optional]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft4/optional]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft6/optional]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7]" - - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite[draft7/optional]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3\]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3/optional\]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft4\]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft4/optional\]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft6\]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft6/optional\]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft7\]" + - TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft7/optional\]" jobs: - include: - - env: TEST_SUITE="PHPModelGenerator" FILTER="." CC_TEST_REPORTER_ID=5e32818628fac9eb11d34e2b35289f88169610cc4a98c6f170c74923342284f1 allow_failures: - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3\]" - env: TEST_SUITE="JsonSchemaTestSuite" FILTER="Draft suite\[draft3/optional\]"