From 41e5796d35eb17ef396ac74e0bddbaa32c279613 Mon Sep 17 00:00:00 2001 From: Antonio Mansilla Date: Mon, 9 Sep 2019 14:42:33 +0200 Subject: [PATCH 1/2] Fix BC break introduced by Akeneo core patch version Fix table attribute bundle issue #32. More info about BC break can be found: https://github.com/akeneo/pim-community-dev/commit/2b6832ee32094fc404f0ce189bc1aae39f28f8f6 --- .../AttributeTypeForOptionValidatorSpec.php | 104 ------------------ src/Resources/config/validators.xml | 7 +- .../AttributeTypeForOptionValidator.php | 38 ------- 3 files changed, 6 insertions(+), 143 deletions(-) delete mode 100644 spec/Flagbit/Bundle/TableAttributeBundle/Validator/Constraints/AttributeTypeForOptionValidatorSpec.php delete mode 100644 src/Validator/Constraints/AttributeTypeForOptionValidator.php diff --git a/spec/Flagbit/Bundle/TableAttributeBundle/Validator/Constraints/AttributeTypeForOptionValidatorSpec.php b/spec/Flagbit/Bundle/TableAttributeBundle/Validator/Constraints/AttributeTypeForOptionValidatorSpec.php deleted file mode 100644 index b1e3c82..0000000 --- a/spec/Flagbit/Bundle/TableAttributeBundle/Validator/Constraints/AttributeTypeForOptionValidatorSpec.php +++ /dev/null @@ -1,104 +0,0 @@ -shouldHaveType(AttributeTypeForOptionValidator::class); - } - - public function it_validates_option_simple_select( - AttributeOptionInterface $attributeOption, - Attribute $attributeModel - ) - { - $expectedViolations = 0; - $this->checkViolations(AttributeTypes::OPTION_SIMPLE_SELECT, $attributeOption, $attributeModel, $expectedViolations); - } - - public function it_validates_option_multi_select( - AttributeOptionInterface $attributeOption, - Attribute $attributeModel - ) - { - $expectedViolations = 0; - $this->checkViolations(AttributeTypes::OPTION_MULTI_SELECT, $attributeOption, $attributeModel, $expectedViolations); - } - - public function it_validates_flagbit_table( - AttributeOptionInterface $attributeOption, - Attribute $attributeModel - ) - { - $expectedViolations = 0; - $this->checkViolations(TableType::FLAGBIT_CATALOG_TABLE, $attributeOption, $attributeModel, $expectedViolations); - } - - public function it_finds_violations_for_wrong_attribute_type( - AttributeOptionInterface $attributeOption, - Attribute $attributeModel - ) - { - $expectedViolations = 1; - $type = "wrong_type"; - - $this->checkViolations($type, $attributeOption, $attributeModel, $expectedViolations); - } - - private function checkViolations( - String $type, - AttributeOptionInterface $attributeOption, - Attribute $attributeModel, - int $expectedViolations - ) - { - $validator = (new ValidatorBuilder())->getValidator(); - $executionContext = (new ExecutionContextFactory(new IdentityTranslator()))->createContext($validator, ''); - $executionContext->setConstraint($this->createAttributeTypeForOptionConstraint()); - - $this->initialize($executionContext); - $attributeModel->getType()->willReturn($type); - $attributeModel->getCode()->willReturn('22'); - $attributeOption->getAttribute()->willReturn($attributeModel); - - $this->validate($attributeOption, $this->createAttributeTypeForOptionConstraint())->shouldHaveViolations($executionContext, $expectedViolations); - } - - /** - * @return array - */ - public function getMatchers(): array - { - return [ - 'haveViolations' => function ($subject, $context, $count) { - $violationCount = count($context->getViolations()); - if ($violationCount !== $count) { - throw new FailureException(sprintf('Expected violations: %d, but %d occured', $count, $violationCount)); - } - return true; - } - ]; - } - - /** - * @return AttributeTypeForOption - */ - private function createAttributeTypeForOptionConstraint() - { - return new AttributeTypeForOption(); - } -} diff --git a/src/Resources/config/validators.xml b/src/Resources/config/validators.xml index 6b68d96..382885a 100644 --- a/src/Resources/config/validators.xml +++ b/src/Resources/config/validators.xml @@ -10,8 +10,13 @@ - + + pim_catalog_simpleselect + pim_catalog_multiselect + flagbit_catalog_table + diff --git a/src/Validator/Constraints/AttributeTypeForOptionValidator.php b/src/Validator/Constraints/AttributeTypeForOptionValidator.php deleted file mode 100644 index 775248f..0000000 --- a/src/Validator/Constraints/AttributeTypeForOptionValidator.php +++ /dev/null @@ -1,38 +0,0 @@ -getAttribute(); - $authorizedTypes = [ - AttributeTypes::OPTION_SIMPLE_SELECT, - AttributeTypes::OPTION_MULTI_SELECT, - TableType::FLAGBIT_CATALOG_TABLE, - ]; - - if (!in_array($attribute->getType(), $authorizedTypes, true)) { - $this->addInvalidAttributeViolation($constraint, $attributeOption, $authorizedTypes); - } - } - } -} From 0c7d9c0c081969ffb1b39841dcf1f35e929fee75 Mon Sep 17 00:00:00 2001 From: Antonio Mansilla Date: Mon, 9 Sep 2019 15:13:42 +0200 Subject: [PATCH 2/2] Update Akeneo compatibility >= 3.0.21 or >= 3.2.0 --- README.md | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 35f1ee4..bc4e01b 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ php bin/console --env=prod doctrine:migrations:migrate This extension supports the latest Akeneo PIM CE/EE stable versions: +* 3.2 (LTS) * 3.0 (LTS) * 2.3 (LTS) diff --git a/composer.json b/composer.json index f55d8c2..c59e043 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ ], "require": { "ext-json": "*", - "akeneo/pim-community-dev": "^3.0.0" + "akeneo/pim-community-dev": "~3.0.21 || ~3.2.0" }, "require-dev": { "phpspec/phpspec": "^5.1",