Merge branch 'release/3.1.0'
All checks were successful
ci/woodpecker/tag/code-style Pipeline was successful
ci/woodpecker/tag/test Pipeline was successful

This commit is contained in:
Robin Krahnen 2022-05-04 23:41:58 +02:00
commit 46d7692ded
12 changed files with 93 additions and 33 deletions

View file

@ -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/

25
.woodpecker/test.yml Normal file
View file

@ -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"

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace DigiComp\SettingValidator; namespace DigiComp\SettingValidator;
/* /*
@ -22,17 +24,18 @@ use Neos\Flow\Package\Package as NeosFlowPackagePackage;
class Package extends NeosFlowPackagePackage class Package extends NeosFlowPackagePackage
{ {
/** /**
* @param Bootstrap $bootstrap * @inheritDoc
*/ */
public function boot(Bootstrap $bootstrap): void public function boot(Bootstrap $bootstrap): void
{ {
parent::boot($bootstrap); parent::boot($bootstrap);
$dispatcher = $bootstrap->getSignalSlotDispatcher(); $dispatcher = $bootstrap->getSignalSlotDispatcher();
$dispatcher->connect( $dispatcher->connect(
ConfigurationManager::class, ConfigurationManager::class,
'configurationManagerReady', 'configurationManagerReady',
function (ConfigurationManager $configurationManager) { function (ConfigurationManager $configurationManager): void {
$configurationManager->registerConfigurationType('Validation'); $configurationManager->registerConfigurationType('Validation');
} }
); );

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace DigiComp\SettingValidator\Validation\Validator; namespace DigiComp\SettingValidator\Validation\Validator;
/* /*

View file

@ -8,11 +8,6 @@ DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject:
expectedValue: false expectedValue: false
Grumble: ~ Grumble: ~
TrueValidator:
self:
BooleanValue:
expectedValue: true
DigiComp\SettingValidator\Tests\Functional\Fixtures\TestValidationGroupsCustomObject: DigiComp\SettingValidator\Tests\Functional\Fixtures\TestValidationGroupsCustomObject:
self: self:
DigiComp.SettingValidator:Settings: DigiComp.SettingValidator:Settings:
@ -36,3 +31,8 @@ GroupValidatorCustom:
expectedValue: false expectedValue: false
validationGroups: validationGroups:
- "Custom" - "Custom"
TrueValidator:
self:
BooleanValue:
expectedValue: true

View file

@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace Neos\Flow\Core\Migrations; namespace Neos\Flow\Core\Migrations;
/** /**
@ -15,11 +17,14 @@ class Version20170603120900 extends AbstractMigration
return 'DigiComp.SettingValidator-20170603120900'; return 'DigiComp.SettingValidator-20170603120900';
} }
/**
* @inheritDoc
*/
public function up(): void public function up(): void
{ {
$this->processConfiguration( $this->processConfiguration(
'Validation', 'Validation',
function (array &$configuration) { function (array &$configuration): void {
foreach ($configuration as $validatorName => &$validators) { foreach ($configuration as $validatorName => &$validators) {
// guard that protects configuration, which has already the new format: // guard that protects configuration, which has already the new format:
if (isset($validators['properties']) || isset($validators['self'])) { if (isset($validators['properties']) || isset($validators['self'])) {

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace DigiComp\SettingValidator\Tests\Functional\Fixtures; namespace DigiComp\SettingValidator\Tests\Functional\Fixtures;
use Neos\Flow\Annotations as Flow; use Neos\Flow\Annotations as Flow;

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace DigiComp\SettingValidator\Tests\Functional\Fixtures; namespace DigiComp\SettingValidator\Tests\Functional\Fixtures;
class TestValidationGroupsCustomObject class TestValidationGroupsCustomObject

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace DigiComp\SettingValidator\Tests\Functional\Fixtures; namespace DigiComp\SettingValidator\Tests\Functional\Fixtures;
class TestValidationGroupsDefaultObject class TestValidationGroupsDefaultObject

View file

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace DigiComp\SettingValidator\Tests\Functional; namespace DigiComp\SettingValidator\Tests\Functional;
use DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject; use DigiComp\SettingValidator\Tests\Functional\Fixtures\TestObject;
@ -20,11 +22,11 @@ class SettingsValidatorTest extends FunctionalTestCase
*/ */
public function ifNoNameIsGivenClassNameIsUsed(): void public function ifNoNameIsGivenClassNameIsUsed(): void
{ {
$validator = $this->objectManager->get(SettingsValidator::class); $result = $this->objectManager->get(SettingsValidator::class)->validate(new TestObject());
$result = $validator->validate(new TestObject());
$this->assertTrue($result->hasErrors()); self::assertTrue($result->hasErrors());
$this->assertCount(1, $result->getFlattenedErrors()); self::assertCount(1, $result->getFlattenedErrors());
$this->assertCount(1, $result->forProperty('shouldBeFalse')->getErrors()); self::assertCount(1, $result->forProperty('shouldBeFalse')->getErrors());
} }
/** /**
@ -35,11 +37,13 @@ class SettingsValidatorTest extends FunctionalTestCase
*/ */
public function conjunctionValidationWorksAsExpected(): void public function conjunctionValidationWorksAsExpected(): void
{ {
$validatorResolver = $this->objectManager->get(ValidatorResolver::class); $result = $this->objectManager
$validator = $validatorResolver->getBaseValidatorConjunction(TestObject::class); ->get(ValidatorResolver::class)
$result = $validator->validate(new TestObject()); ->getBaseValidatorConjunction(TestObject::class)
$this->assertTrue($result->hasErrors()); ->validate(new TestObject());
$this->assertCount(1, $result->getFlattenedErrors());
self::assertTrue($result->hasErrors());
self::assertCount(1, $result->getFlattenedErrors());
} }
/** /**
@ -48,11 +52,13 @@ class SettingsValidatorTest extends FunctionalTestCase
*/ */
public function defaultValidationGroupWorks(): void public function defaultValidationGroupWorks(): void
{ {
$validator = $this->objectManager->get(SettingsValidator::class, ['validationGroups' => ['Default']]); $result = $this->objectManager
$result = $validator->validate(new TestValidationGroupsDefaultObject()); ->get(SettingsValidator::class, ['validationGroups' => ['Default']])
$this->assertTrue($result->hasErrors(), 'No Errors for validation group "Default"'); ->validate(new TestValidationGroupsDefaultObject());
$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'); 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 public function customValidationGroupWorks(): void
{ {
$validator = $this->objectManager->get(SettingsValidator::class, ['validationGroups' => ['Custom']]); $result = $this->objectManager
$result = $validator->validate(new TestValidationGroupsCustomObject()); ->get(SettingsValidator::class, ['validationGroups' => ['Custom']])
$this->assertTrue($result->hasErrors(), 'No Errors for validation group "Custom"'); ->validate(new TestValidationGroupsCustomObject());
$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'); 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');
} }
} }

View file

@ -4,7 +4,10 @@
"type": "neos-package", "type": "neos-package",
"require": { "require": {
"neos/flow": "^6.3.5", "neos/flow": "^6.3.5",
"php": "~7.4.0" "php": ">=7.4"
},
"require-dev": {
"phpunit/phpunit": "~8.5"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -21,7 +24,8 @@
"package-key": "DigiComp.SettingValidator" "package-key": "DigiComp.SettingValidator"
}, },
"branch-alias": { "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" "dev-version/1.x-dev": "1.0.x-dev"
}, },
"applied-flow-migrations": [ "applied-flow-migrations": [
@ -65,12 +69,12 @@
{ {
"name": "Ferdinand Kuhl", "name": "Ferdinand Kuhl",
"email": "f.kuhl@digital-competence.de", "email": "f.kuhl@digital-competence.de",
"homepage": "http://www.digital-competence.de", "homepage": "https://www.digital-competence.de",
"role": "Developer" "role": "Developer"
} }
], ],
"license": "MIT", "license": "MIT",
"homepage": "https://github.com/fcool/DigiComp.SettingValidator", "homepage": "https://github.com/digital-competence/DigiComp.SettingValidator",
"keywords": [ "keywords": [
"Neos", "Neos",
"Flow", "Flow",