-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from flagbit/3.0
Add support for Akeneo 3.0
- Loading branch information
Showing
45 changed files
with
618 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# 3.0.0 | ||
|
||
- Add support for Akeneo 3.0.0. | ||
|
||
## BC breaks | ||
|
||
- `Flagbit\Bundle\TableAttributeBundle\Normalizer\StructuredAttributeOptionNormalizer` was deleted. `Flagbit\Bundle\TableAttributeBundle\Normalizer\AttributeOptionNormalizer` is now used for its service. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
spec/Flagbit/Bundle/TableAttributeBundle/AttributeType/TableTypeSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\AttributeType; | ||
|
||
use Flagbit\Bundle\TableAttributeBundle\AttributeType\TableType; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class TableTypeSpec extends ObjectBehavior | ||
{ | ||
public function let() | ||
{ | ||
$this->beConstructedWith('text'); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(TableType::class); | ||
} | ||
|
||
public function it_returns_flagbit_catalog_table() | ||
{ | ||
$this->getName()->shouldReturn('flagbit_catalog_table'); | ||
} | ||
|
||
public function it_returns_text_forbackend_type() | ||
{ | ||
$this->getBackendType()->shouldReturn('text'); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
spec/Flagbit/Bundle/TableAttributeBundle/DependencyInjection/ConfigurationSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\DependencyInjection; | ||
|
||
use Flagbit\Bundle\TableAttributeBundle\DependencyInjection\Configuration; | ||
use Symfony\Component\Config\Definition\Builder\TreeBuilder; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class ConfigurationSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(Configuration::class); | ||
} | ||
|
||
public function it_returns_Treebuilder_object() | ||
{ | ||
$this->getConfigTreeBuilder()->shouldBeAnInstanceOf(TreeBuilder::Class); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
spec/Flagbit/Bundle/TableAttributeBundle/Form/TableJsonTransformerSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\Form; | ||
|
||
use Flagbit\Bundle\TableAttributeBundle\Form\TableJsonTransformer; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
class TableJsonTransformerSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(TableJsonTransformer::class); | ||
} | ||
|
||
public function it_keeps_transform_value() | ||
{ | ||
$originalValue = '{"Blank":{},"NotNull":{}}'; | ||
$expectedvalue = '{"Blank":{},"NotNull":{}}'; | ||
|
||
$this->transform($originalValue)->shouldBe($expectedvalue); | ||
} | ||
|
||
public function it_reverse_transforms_to_constraints_array_format() | ||
{ | ||
$originalValue = '{"Blank":{},"NotNull":{}}'; | ||
$expectedvalue = [ | ||
'Blank' => [], | ||
'NotNull' => [], | ||
]; | ||
|
||
$this->reverseTransform($originalValue)->shouldBe($expectedvalue); | ||
} | ||
|
||
public function it_reverse_transform_null() | ||
{ | ||
$originalValue = null; | ||
|
||
$this->reverseTransform($originalValue)->shouldBeNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
spec/Flagbit/Bundle/TableAttributeBundle/Normalizer/AttributeOptionNormalizerSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\Normalizer; | ||
|
||
use Flagbit\Bundle\TableAttributeBundle\Entity\AttributeOption; | ||
use Flagbit\Bundle\TableAttributeBundle\Normalizer\AttributeOptionNormalizer; | ||
use PhpSpec\ObjectBehavior; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
class AttributeOptionNormalizerSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(AttributeOptionNormalizer::class); | ||
} | ||
|
||
public function let(NormalizerInterface $baseNormalizer) | ||
{ | ||
$this->beConstructedWith($baseNormalizer); | ||
} | ||
|
||
public function it_checks_return_type_array_and_right_values | ||
( | ||
AttributeOption $attributeOption, | ||
$baseNormalizer | ||
) | ||
{ | ||
$constraints = [ | ||
'NotBlank' => [], | ||
'Email' => [], | ||
]; | ||
|
||
$activatedLocales = [ | ||
'onlyActivatedLocales' => true, | ||
]; | ||
|
||
$baseNormalizer->normalize($attributeOption, 'array', $activatedLocales)->shouldBeCalled(); | ||
$attributeOption->getType()->willReturn('text'); | ||
$attributeOption->getTypeConfig()->willReturn([]); | ||
$attributeOption->getConstraints()->willReturn($constraints); | ||
|
||
$normalizedValues = $this->normalize($attributeOption, 'array', $activatedLocales); | ||
|
||
$normalizedValues->shouldBeArray(); | ||
|
||
$normalizedValues->shouldHaveKey('type'); | ||
$normalizedValues->shouldHaveKey('type_config'); | ||
$normalizedValues->shouldHaveKey('constraints'); | ||
|
||
$normalizedValues->shouldHaveKeyWithValue('type', 'text'); | ||
$normalizedValues->shouldHaveKeyWithValue('type_config', []); | ||
$normalizedValues->shouldHaveKeyWithValue('constraints', $constraints); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
spec/Flagbit/Bundle/TableAttributeBundle/Provider/Field/TableFieldProviderSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\Provider\Field; | ||
|
||
use Flagbit\Bundle\TableAttributeBundle\Provider\Field\TableFieldProvider; | ||
use PhpSpec\ObjectBehavior; | ||
use Akeneo\Pim\Structure\Component\Model\AttributeInterface; | ||
|
||
|
||
class TableFieldProviderSpec extends ObjectBehavior | ||
{ | ||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(TableFieldProvider::class); | ||
} | ||
|
||
public function it_returns_flagbit_table_field() | ||
{ | ||
$element = [ | ||
'foo' => 'bar', | ||
]; | ||
$this->getField($element)->shouldReturn('flagbit-table-field'); | ||
} | ||
|
||
public function it_checks_correct_support | ||
( | ||
AttributeInterface $attributeInterface | ||
) | ||
{ | ||
$attributeInterface->getType()->willReturn('flagbit_catalog_table'); | ||
$this->supports($attributeInterface)->shouldReturn(true); | ||
} | ||
|
||
public function it_checks_incorrect_support | ||
( | ||
AttributeInterface $attributeInterface | ||
) | ||
{ | ||
$attributeInterface->getType()->willReturn('foo_bar'); | ||
$this->supports($attributeInterface)->shouldReturn(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
spec/Flagbit/Bundle/TableAttributeBundle/Validator/ConstraintGuesser/TableGuesserSpec.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace spec\Flagbit\Bundle\TableAttributeBundle\Validator\ConstraintGuesser; | ||
|
||
use Akeneo\Pim\Structure\Component\Model\AttributeInterface; | ||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Flagbit\Bundle\TableAttributeBundle\AttributeType\TableType; | ||
use Flagbit\Bundle\TableAttributeBundle\Entity\AttributeOption; | ||
use Flagbit\Bundle\TableAttributeBundle\Validator\ConstraintFactory; | ||
use Flagbit\Bundle\TableAttributeBundle\Validator\ConstraintGuesser\TableGuesser; | ||
use Flagbit\Bundle\TableAttributeBundle\Validator\Constraints\Table; | ||
use PhpSpec\ObjectBehavior; | ||
use Symfony\Component\Validator\Constraint; | ||
|
||
class TableGuesserSpec extends ObjectBehavior | ||
{ | ||
public function let(ConstraintFactory $constraintFactory) | ||
{ | ||
$this->beConstructedWith($constraintFactory); | ||
} | ||
|
||
public function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(TableGuesser::class); | ||
} | ||
|
||
public function it_supports_table_attribute(AttributeInterface $attribute) | ||
{ | ||
$attribute->getType()->willReturn(TableType::FLAGBIT_CATALOG_TABLE); | ||
$this->supportAttribute($attribute)->shouldReturn(true); | ||
} | ||
|
||
public function it_not_supports_wrong_type(AttributeInterface $attribute) | ||
{ | ||
$attribute->getType()->willReturn('not_existing_type'); | ||
$this->supportAttribute($attribute)->shouldReturn(false); | ||
} | ||
|
||
public function it_creates_constraint_array( | ||
AttributeInterface $attribute, | ||
AttributeOption $attributeOption, | ||
ConstraintFactory $constraintFactory, | ||
Constraint $notBlank, | ||
Constraint $email, | ||
Table $tableConstraint | ||
) | ||
{ | ||
$attribute->getOptions()->willReturn(new ArrayCollection([ | ||
$attributeOption->getWrappedObject(), | ||
])); | ||
$constraints = [ | ||
$notBlank, | ||
]; | ||
|
||
$attributeOption->getCode()->willReturn('foo'); | ||
$constraintFactory->createByConstraintConfig($attributeOption)->willReturn($constraints); | ||
|
||
$fieldConstraints['foo'] = $constraints; | ||
$constraintFactory->createTableConstraint($fieldConstraints)->willReturn($tableConstraint); | ||
$this->guessConstraints($attribute)->shouldBeArray(); | ||
$this->guessConstraints($attribute)->shouldReturn([$tableConstraint]); | ||
} | ||
|
||
public function it_creates_constraint_array_without_options( | ||
AttributeInterface $attribute, | ||
ConstraintFactory $constraintFactory, | ||
Table $tableConstraint | ||
) | ||
{ | ||
$attribute->getOptions()->willReturn([]); | ||
$fieldConstraints = []; | ||
$constraintFactory->createTableConstraint($fieldConstraints)->willReturn($tableConstraint); | ||
$this->guessConstraints($attribute)->shouldBeArray(); | ||
$this->guessConstraints($attribute)->shouldReturn([$tableConstraint]); | ||
} | ||
} |
Oops, something went wrong.