diff --git a/.woodpecker/code-style.yml b/.woodpecker/code-style.yml new file mode 100644 index 0000000..453df4b --- /dev/null +++ b/.woodpecker/code-style.yml @@ -0,0 +1,7 @@ +pipeline: + code-style: + image: composer + commands: + - composer global config repositories.repo-name vcs https://git.digital-competence.de/Packages/php-codesniffer + - composer global require digicomp/php-codesniffer:@dev + - composer global exec -- phpcs --runtime-set ignore_warnings_on_exit 1 --standard=DigiComp Classes/ Migrations/ Tests/ Resources/Private/ diff --git a/.woodpecker/test.yml b/.woodpecker/test.yml new file mode 100644 index 0000000..1315875 --- /dev/null +++ b/.woodpecker/test.yml @@ -0,0 +1,25 @@ +workspace: + base: /woodpecker + path: package + +matrix: + FLOW_VERSION: + - 6.3 + +pipeline: + functional-tests: + image: thecodingmachine/php:7.4-v4-cli + environment: + # Enable the PDO_SQLITE extension + - "PHP_EXTENSION_PDO_SQLITE=1" + - "FLOW_VERSION=${FLOW_VERSION}" + - "NEOS_BUILD_DIR=/woodpecker/Build-${FLOW_VERSION}" + commands: + - "sudo mkdir $NEOS_BUILD_DIR" + - "sudo chown -R docker:docker $NEOS_BUILD_DIR" + - "cd $NEOS_BUILD_DIR" + - "composer create-project --no-install neos/flow-base-distribution:^$FLOW_VERSION ." + - "composer config repositories.repo-name path /woodpecker/package" + - "composer remove --dev neos/behat" + - "composer require digicomp/settingvalidator:@dev" + - "bin/phpunit --configuration Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/DigiComp.SettingValidator/Tests/Functional" diff --git a/Classes/Package.php b/Classes/Package.php index cd71a3c..2335797 100644 --- a/Classes/Package.php +++ b/Classes/Package.php @@ -1,5 +1,7 @@ getSignalSlotDispatcher(); + $dispatcher->connect( ConfigurationManager::class, 'configurationManagerReady', - function (ConfigurationManager $configurationManager) { + function (ConfigurationManager $configurationManager): void { $configurationManager->registerConfigurationType('Validation'); } ); diff --git a/Classes/Validation/Validator/SettingsValidator.php b/Classes/Validation/Validator/SettingsValidator.php index 8b825d8..46715de 100644 --- a/Classes/Validation/Validator/SettingsValidator.php +++ b/Classes/Validation/Validator/SettingsValidator.php @@ -1,5 +1,7 @@ processConfiguration( 'Validation', - function (array &$configuration) { + function (array &$configuration): void { foreach ($configuration as $validatorName => &$validators) { // guard that protects configuration, which has already the new format: if (isset($validators['properties']) || isset($validators['self'])) { diff --git a/Tests/Functional/Fixtures/TestObject.php b/Tests/Functional/Fixtures/TestObject.php index 6f8e667..4d65558 100644 --- a/Tests/Functional/Fixtures/TestObject.php +++ b/Tests/Functional/Fixtures/TestObject.php @@ -1,5 +1,7 @@ objectManager->get(SettingsValidator::class); - $result = $validator->validate(new TestObject()); - $this->assertTrue($result->hasErrors()); - $this->assertCount(1, $result->getFlattenedErrors()); - $this->assertCount(1, $result->forProperty('shouldBeFalse')->getErrors()); + $result = $this->objectManager->get(SettingsValidator::class)->validate(new TestObject()); + + self::assertTrue($result->hasErrors()); + self::assertCount(1, $result->getFlattenedErrors()); + self::assertCount(1, $result->forProperty('shouldBeFalse')->getErrors()); } /** @@ -35,11 +37,13 @@ class SettingsValidatorTest extends FunctionalTestCase */ public function conjunctionValidationWorksAsExpected(): void { - $validatorResolver = $this->objectManager->get(ValidatorResolver::class); - $validator = $validatorResolver->getBaseValidatorConjunction(TestObject::class); - $result = $validator->validate(new TestObject()); - $this->assertTrue($result->hasErrors()); - $this->assertCount(1, $result->getFlattenedErrors()); + $result = $this->objectManager + ->get(ValidatorResolver::class) + ->getBaseValidatorConjunction(TestObject::class) + ->validate(new TestObject()); + + self::assertTrue($result->hasErrors()); + self::assertCount(1, $result->getFlattenedErrors()); } /** @@ -48,11 +52,13 @@ class SettingsValidatorTest extends FunctionalTestCase */ public function defaultValidationGroupWorks(): void { - $validator = $this->objectManager->get(SettingsValidator::class, ['validationGroups' => ['Default']]); - $result = $validator->validate(new TestValidationGroupsDefaultObject()); - $this->assertTrue($result->hasErrors(), 'No Errors for validation group "Default"'); - $this->assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Default"'); - $this->assertCount(1, $result->forProperty('shouldBeTrue')->getErrors(), 'Got no error for property'); + $result = $this->objectManager + ->get(SettingsValidator::class, ['validationGroups' => ['Default']]) + ->validate(new TestValidationGroupsDefaultObject()); + + self::assertTrue($result->hasErrors(), 'No errors for validation group "Default"'); + self::assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Default"'); + self::assertCount(1, $result->forProperty('shouldBeTrue')->getErrors(), 'Got no error for property'); } /** @@ -61,10 +67,12 @@ class SettingsValidatorTest extends FunctionalTestCase */ public function customValidationGroupWorks(): void { - $validator = $this->objectManager->get(SettingsValidator::class, ['validationGroups' => ['Custom']]); - $result = $validator->validate(new TestValidationGroupsCustomObject()); - $this->assertTrue($result->hasErrors(), 'No Errors for validation group "Custom"'); - $this->assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Custom"'); - $this->assertCount(1, $result->forProperty('shouldBeFalse')->getErrors(), 'Got no error for property'); + $result = $this->objectManager + ->get(SettingsValidator::class, ['validationGroups' => ['Custom']]) + ->validate(new TestValidationGroupsCustomObject()); + + self::assertTrue($result->hasErrors(), 'No errors for validation group "Custom"'); + self::assertCount(1, $result->getFlattenedErrors(), 'Got a non expected number of errors for group "Custom"'); + self::assertCount(1, $result->forProperty('shouldBeFalse')->getErrors(), 'Got no error for property'); } } diff --git a/composer.json b/composer.json index d3f47f9..db62c95 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,10 @@ "type": "neos-package", "require": { "neos/flow": "^6.3.5", - "php": "~7.4.0" + "php": ">=7.4" + }, + "require-dev": { + "phpunit/phpunit": "~8.5" }, "autoload": { "psr-4": { @@ -21,7 +24,8 @@ "package-key": "DigiComp.SettingValidator" }, "branch-alias": { - "dev-develop": "3.0.x-dev", + "dev-develop": "3.1.x-dev", + "dev-version/2.x-dev": "2.1.x-dev", "dev-version/1.x-dev": "1.0.x-dev" }, "applied-flow-migrations": [ @@ -65,12 +69,12 @@ { "name": "Ferdinand Kuhl", "email": "f.kuhl@digital-competence.de", - "homepage": "http://www.digital-competence.de", + "homepage": "https://www.digital-competence.de", "role": "Developer" } ], "license": "MIT", - "homepage": "https://github.com/fcool/DigiComp.SettingValidator", + "homepage": "https://github.com/digital-competence/DigiComp.SettingValidator", "keywords": [ "Neos", "Flow",