diff --git a/.scrutinizer.yml b/.scrutinizer.yml
new file mode 100644
index 0000000..a9ce3bf
--- /dev/null
+++ b/.scrutinizer.yml
@@ -0,0 +1,13 @@
+build:
+ nodes:
+ analysis:
+ environment:
+ apt_packages:
+ - libmagickwand-dev
+ - libmagickcore-dev
+ php:
+ version: 7.3
+ pecl_extensions:
+ - apcu
+ - imagick
+ - zip
diff --git a/.travis.yml b/.travis.yml
index 049c5cf..2dcca32 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,9 +14,6 @@ cache:
matrix:
fast_finish: true
include:
- - php: 7.2
- - php: 7.3
- allow_failures:
- php: 7.3
before_install:
diff --git a/README.md b/README.md
index bc4e01b..9557e86 100644
--- a/README.md
+++ b/README.md
@@ -60,21 +60,17 @@ Enable the bundle in the kernel:
``` php
['all' => true],
+];
```
### Configuration
-Add `mapping_overrides` in `app/config/config.yml`:
+Add `mapping_overrides` in a new `config/packages/table.yml` file or an existing one:
``` yml
akeneo_storage_utils:
@@ -99,8 +95,7 @@ php bin/console --env=prod doctrine:schema:update --force
Build and install the new front-end dependencies (new icon, etc.)
``` bash
-php bin/console --env=prod pim:installer:assets --symlink --clean
-yarn run webpack
+make cache assets css javascript-prod
```
In case you're using Doctrine migrations, you have to create a new migration class
@@ -119,6 +114,7 @@ php bin/console --env=prod doctrine:migrations:migrate
This extension supports the latest Akeneo PIM CE/EE stable versions:
+* 4.0
* 3.2 (LTS)
* 3.0 (LTS)
* 2.3 (LTS)
diff --git a/composer.json b/composer.json
index 4bc2215..0ad1b84 100644
--- a/composer.json
+++ b/composer.json
@@ -32,22 +32,17 @@
"Flagbit\\Bundle\\TableAttributeBundle\\Test\\": "tests/"
}
},
- "repositories": [
- {
- "type": "vcs",
- "url": "https://github.com/akeneo/pim-community-dev.git",
- "branch": "master",
- "no-api": true
- }
- ],
"require": {
"ext-json": "*",
- "akeneo/pim-community-dev": "^3.2"
+ "akeneo/pim-community-dev": "^4.0"
},
"require-dev": {
- "phpspec/phpspec": "^5.1",
- "phpunit/phpunit": "^7.1",
- "squizlabs/php_codesniffer": "*",
- "overtrue/phplint": "*"
+ "phpspec/phpspec": "^6.1",
+ "phpunit/phpunit": "^8.0",
+ "squizlabs/php_codesniffer": "^3.5",
+ "overtrue/phplint": "^1.2",
+ "symfony/debug-bundle": "^4.4",
+ "symfony/web-profiler-bundle": "^4.4",
+ "symfony/web-server-bundle": "^4.4"
}
}
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index a112386..85ae625 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -17,6 +17,14 @@
+
+
+
+
+
+
+
+
diff --git a/spec/Flagbit/Bundle/TableAttributeBundle/Component/Product/Completeness/MaskItemGenerator/TableMaskItemSpec.php b/spec/Flagbit/Bundle/TableAttributeBundle/Component/Product/Completeness/MaskItemGenerator/TableMaskItemSpec.php
new file mode 100644
index 0000000..685ae6c
--- /dev/null
+++ b/spec/Flagbit/Bundle/TableAttributeBundle/Component/Product/Completeness/MaskItemGenerator/TableMaskItemSpec.php
@@ -0,0 +1,24 @@
+shouldHaveType(TableMaskItem::class);
+ }
+
+ public function it_masks_for_raw_value()
+ {
+ $this->forRawValue('a', 'b', 'c', 'd')->shouldBe(['a-b-c']);
+ }
+
+ public function it_supports_attribute_types()
+ {
+ $this->supportedAttributeTypes()->shouldBe(['flagbit_catalog_table']);
+ }
+}
diff --git a/spec/Flagbit/Bundle/TableAttributeBundle/Component/Product/Factory/Value/TableValueFactorySpec.php b/spec/Flagbit/Bundle/TableAttributeBundle/Component/Product/Factory/Value/TableValueFactorySpec.php
new file mode 100644
index 0000000..ecd38ad
--- /dev/null
+++ b/spec/Flagbit/Bundle/TableAttributeBundle/Component/Product/Factory/Value/TableValueFactorySpec.php
@@ -0,0 +1,74 @@
+shouldHaveType(TableValueFactory::class);
+ }
+
+ public function it_creates_scopable_and_localizable_table_value()
+ {
+ $attribute = $this->createAttribute(true, true);
+
+ $this->createByCheckingData($attribute, 'channelCode', 'de_DE', 'data')
+ ->shouldBeLike(ScalarValue::scopableLocalizableValue('code', 'data', 'channelCode', 'de_DE'));
+ }
+
+ public function it_creates_scopable_table_value()
+ {
+ $attribute = $this->createAttribute(true, false);
+
+ $this->createByCheckingData($attribute, 'channelCode', null, 'data')
+ ->shouldBeLike(ScalarValue::scopableValue('code', 'data', 'channelCode'));
+ }
+
+ public function it_creates_localizable_table_value()
+ {
+ $attribute = $this->createAttribute(false, true);
+
+ $this->createByCheckingData($attribute, null, 'de_DE', 'data')
+ ->shouldBeLike(ScalarValue::localizableValue('code', 'data', 'de_DE'));
+ }
+
+ public function it_creates_table_value()
+ {
+ $attribute = $this->createAttribute(false, false);
+
+ $this->createByCheckingData($attribute, null, null, 'data')
+ ->shouldBeLike(ScalarValue::value('code', 'data'));
+ }
+
+ public function it_throws_exception_on_nonscalar_data()
+ {
+ $attribute = $this->createAttribute(false, false);
+
+ $this->shouldThrow()->during('createByCheckingData', [$attribute, null, null, new EmptyIterator()]);
+ }
+
+ public function it_throws_exception_on_empty_data()
+ {
+ $attribute = $this->createAttribute(false, false);
+
+ $this->shouldThrow(InvalidPropertyTypeException::class)->during('createByCheckingData', [$attribute, null, null, "\0\n "]);
+ }
+
+ private function createAttribute(bool $isScopable, bool $isLocalizable): Attribute
+ {
+ return new Attribute('code', 'flagbit_catalog_table', [], $isLocalizable, $isScopable, null, false, 'backend', ['de_DE', 'en_US']);
+ }
+
+ public function it_supports_attribute_type()
+ {
+ $this->supportedAttributeType()->shouldBe('flagbit_catalog_table');
+ }
+}
diff --git a/src/Component/Product/Completeness/MaskItemGenerator/TableMaskItem.php b/src/Component/Product/Completeness/MaskItemGenerator/TableMaskItem.php
new file mode 100644
index 0000000..b1a9173
--- /dev/null
+++ b/src/Component/Product/Completeness/MaskItemGenerator/TableMaskItem.php
@@ -0,0 +1,28 @@
+code(),
+ static::class,
+ $data
+ );
+ }
+
+ return parent::createWithoutCheckingData($attribute, $channelCode, $localeCode, $data);
+ }
+
+ public function supportedAttributeType(): string
+ {
+ return TableType::FLAGBIT_CATALOG_TABLE;
+ }
+}
diff --git a/src/Resources/config/factories.xml b/src/Resources/config/factories.xml
index 2566a21..50f5f2a 100644
--- a/src/Resources/config/factories.xml
+++ b/src/Resources/config/factories.xml
@@ -1,11 +1,9 @@
-
-
- %pim_catalog.entity.value.scalar.class%
- flagbit_catalog_table
+
diff --git a/src/Resources/config/query_builders.xml b/src/Resources/config/query_builders.xml
index 18ed64e..db163c1 100644
--- a/src/Resources/config/query_builders.xml
+++ b/src/Resources/config/query_builders.xml
@@ -21,6 +21,8 @@
+
+
diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml
index 8584cfd..6609254 100644
--- a/src/Resources/config/services.xml
+++ b/src/Resources/config/services.xml
@@ -5,7 +5,7 @@
http://symfony.com/schema/dic/services/services-1.0.xsd">
- Flagbit\Bundle\TableAttributeBundle\Provider\Field\TableFieldProvider
+ Flagbit\Bundle\TableAttributeBundle\Provider\Field\TableFieldProvider
Flagbit\Bundle\TableAttributeBundle\Validator\Constraints\AttributeTypeForOptionValidator
Flagbit\Bundle\TableAttributeBundle\Form\Extension\AttributeOptionTypeExtension
FlagbitTableAttributeBundle:Attribute:Tab/value.html.twig
@@ -13,16 +13,16 @@
+ id="flagbit_table_attribute.normalizer.structured.attribute_option"
+ class="Flagbit\Bundle\TableAttributeBundle\Normalizer\AttributeOptionNormalizer"
+ decorates="pim_enrich.normalizer.structured.attribute_option" decoration-inner-name="pim_enrich.normalizer.structured.attribute_option_base">
+ id="flagbit_table_attribute.normalizer.attribute_option"
+ class="Flagbit\Bundle\TableAttributeBundle\Normalizer\AttributeOptionNormalizer">
@@ -35,5 +35,9 @@
+
+
+
+
diff --git a/src/Resources/public/less/index.less b/src/Resources/public/less/index.less
index 1323239..4fc9d90 100644
--- a/src/Resources/public/less/index.less
+++ b/src/Resources/public/less/index.less
@@ -1 +1 @@
-@import "./web/bundles/flagbittableattribute/less/tableattribute.less";
+@import "./public/bundles/flagbittableattribute/less/tableattribute.less";
diff --git a/tests/AttributeType/TableTypeTest.php b/tests/AttributeType/TableTypeTest.php
index 4b46563..76693ce 100644
--- a/tests/AttributeType/TableTypeTest.php
+++ b/tests/AttributeType/TableTypeTest.php
@@ -10,7 +10,7 @@ class TableTypeTest extends KernelTestCase
public function testAttributeTypeIsRegisteredCorrect()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$attributeTypeRegistry = $container->get('pim_catalog.registry.attribute_type');
diff --git a/tests/Form/Extension/AttributeOptionTypeExtensionTest.php b/tests/Form/Extension/AttributeOptionTypeExtensionTest.php
index a4988b4..85856ad 100644
--- a/tests/Form/Extension/AttributeOptionTypeExtensionTest.php
+++ b/tests/Form/Extension/AttributeOptionTypeExtensionTest.php
@@ -11,7 +11,7 @@ class AttributeOptionTypeExtensionTest extends KernelTestCase
public function testAttributeOptionTypeExtended()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$formExtension = $container->get('form.extension');
diff --git a/tests/Kernel/EnterpriseFilterStubPass.php b/tests/Kernel/EnterpriseFilterStubPass.php
new file mode 100644
index 0000000..2cdf84b
--- /dev/null
+++ b/tests/Kernel/EnterpriseFilterStubPass.php
@@ -0,0 +1,53 @@
+type = $type;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function process(ContainerBuilder $container)
+ {
+ $registry = $container->getDefinition(sprintf('pimee_workflow.query.filter.%s_registry', $this->type));
+ $filterTag = sprintf('pimee_workflow.elasticsearch.query.%s_filter', $this->type);
+
+ $filters = $this->findTaggedServices($filterTag, $container);
+ foreach ($filters as $filter) {
+ $registry->addMethodCall('register', [$filter]);
+ }
+ }
+
+ private function findTaggedServices(string $tagName, ContainerBuilder $container): array
+ {
+ $services = $container->findTaggedServiceIds($tagName);
+
+ $sortedServices = [];
+ foreach ($services as $serviceId => $tags) {
+ foreach ($tags as $tag) {
+ $priority = $tag['priority'] ?? 30;
+ $sortedServices[$priority][] = new Reference($serviceId);
+ }
+ }
+ krsort($sortedServices);
+
+ return count($sortedServices) > 0 ? array_merge(...$sortedServices) : [];
+ }
+}
diff --git a/tests/Kernel/PublicServiceCompilerPass.php b/tests/Kernel/PublicServiceCompilerPass.php
index 82f44c5..88773f2 100644
--- a/tests/Kernel/PublicServiceCompilerPass.php
+++ b/tests/Kernel/PublicServiceCompilerPass.php
@@ -3,13 +3,11 @@
namespace Flagbit\Bundle\TableAttributeBundle\Test\Kernel;
-
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class PublicServiceCompilerPass implements CompilerPassInterface
{
-
/**
* @var array
*/
@@ -17,7 +15,6 @@ class PublicServiceCompilerPass implements CompilerPassInterface
public function __construct(array $serviceIds)
{
-
$this->serviceIds = $serviceIds;
}
@@ -27,4 +24,4 @@ public function process(ContainerBuilder $container)
$container->getDefinition($serviceId)->setPublic(true);
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/Kernel/TestKernel.php b/tests/Kernel/TestKernel.php
index 8d29fd0..f2b2864 100644
--- a/tests/Kernel/TestKernel.php
+++ b/tests/Kernel/TestKernel.php
@@ -2,59 +2,45 @@
namespace Flagbit\Bundle\TableAttributeBundle\Test\Kernel;
-require_once __DIR__.'/../../vendor/akeneo/pim-community-dev/app/AppKernel.php';
+require_once __DIR__.'/../../vendor/akeneo/pim-community-dev/src/Kernel.php';
-use Flagbit\Bundle\TableAttributeBundle\FlagbitTableAttributeBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-class TestKernel extends \AppKernel
+class TestKernel extends \Kernel
{
- /**
- * Registers your custom bundles
- *
- * @return array
- */
- protected function registerProjectBundles()
+ public function registerBundles(): iterable
{
- return [
- new FlagbitTableAttributeBundle(),
- ];
+ $bundles = require __DIR__ . '/../../vendor/akeneo/pim-community-dev/config/bundles.php';
+ $bundles += require __DIR__ . '/config/bundles.php';
+
+ foreach ($bundles as $class => $envs) {
+ if ($envs[$this->environment] ?? $envs['all'] ?? false) {
+ yield new $class();
+ }
+ }
}
- /**
- * @return string
- */
public function getRootDir(): string
{
return __DIR__;
}
- /**
- * @return string
- */
- public function getCacheDir(): string
- {
- return __DIR__
- . DIRECTORY_SEPARATOR
- . 'var'
- . DIRECTORY_SEPARATOR
- . 'cache'
- . DIRECTORY_SEPARATOR
- . $this->getEnvironment();
- }
-
- /**
- * @return string
- */
- public function getLogDir(): string
+ public function getProjectDir(): string
{
- return __DIR__ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'logs';
+ return __DIR__;
}
protected function build(ContainerBuilder $container)
{
- $serviceIds = ['pim_catalog.validator.constraint_guesser.chained_attribute', 'flagbit_catalog_table.factory.value.table', 'form.extension'];
+ $serviceIds = [
+ 'pim_catalog.validator.constraint_guesser.chained_attribute',
+ 'akeneo.pim.enrichment.factory.value',
+ 'pim_catalog.repository.attribute',
+ 'pim_catalog.repository.cached_attribute',
+ 'form.extension',
+ ];
$container->addCompilerPass(new PublicServiceCompilerPass($serviceIds));
+ $container->addCompilerPass(new EnterpriseFilterStubPass('product_proposal'));
+ $container->addCompilerPass(new EnterpriseFilterStubPass('published_product'));
}
-
}
diff --git a/tests/Kernel/config/bundles.php b/tests/Kernel/config/bundles.php
new file mode 100644
index 0000000..27240c0
--- /dev/null
+++ b/tests/Kernel/config/bundles.php
@@ -0,0 +1,6 @@
+ ['all' => true],
+];
diff --git a/tests/Kernel/config/config_test.yml b/tests/Kernel/config/config_test.yml
deleted file mode 100644
index 3b2fd9a..0000000
--- a/tests/Kernel/config/config_test.yml
+++ /dev/null
@@ -1,99 +0,0 @@
-imports:
- - { resource: '../../../vendor/akeneo/pim-community-dev/app/config/pim_parameters.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/app/config/security.yml' }
- - { resource: 'parameters.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/app/config/security_test.yml' }
- - { resource: 'pim.yml' }
-
-framework:
- test: ~
- session:
- storage_id: session.storage.mock_file
- name: BAPID
- handler_id: session.handler.pdo
- gc_maxlifetime: 3600
- csrf_protection: true
- profiler:
- collect: false
- translator: { fallback: en_US }
- secret: "%secret%"
- router:
- resource: "%kernel.root_dir%/config/routing.yml"
- strict_requirements: "%kernel.debug%"
- form: true
- validation:
- enable_annotations: true
- enabled: true
- templating: { engines: ['twig', 'php'] } #assets_version: SomeVersionScheme
- default_locale: "%locale%"
-
- fragments:
- enabled: true
- path: /_fragment # used for controller action in template
- serializer:
- enabled: true
- http_method_override: true
- assets:
- packages:
- frontend:
- version_strategy: pim_enrich.version_strategy
-
-
-akeneo_pim_structure:
- reference_data:
- assets:
- class: Akeneo\Asset\Component\Model\Asset
- type: multi
-
-# Twig Configuration
-twig:
- debug: "%kernel.debug%"
- strict_variables: "%kernel.debug%"
- globals:
- uservoice_key: "%uservoice_key%"
-web_profiler:
- toolbar: false
- intercept_redirects: false
-
-# Swiftmailer Configuration
-swiftmailer:
- transport: "%mailer_transport%"
- host: "%mailer_host%"
- port: "%mailer_port%"
- encryption: "%mailer_encryption%"
- username: "%mailer_user%"
- password: "%mailer_password%"
- spool: { type: memory }
- disable_delivery: true
-
-monolog:
- handlers:
- main:
- type: stream
- path: "%kernel.logs_dir%/%kernel.environment%.log"
- level: debug
- channels: ['!event']
- firephp:
- type: firephp
- level: info
- console:
- type: console
- channels: ['!event', '!doctrine']
-
-parameters:
- max_products_category_removal: 20
- installer_data: PimInstallerBundle:minimal
- upload_dir: '%kernel.root_dir%/../var/cache/uploads/product'
- archive_dir: '%kernel.root_dir%/../var/cache/archive'
- logs_dir: '%kernel.logs_dir%'
- catalog_storage_dir: '%kernel.root_dir%/../var/cache/file_storage/catalog'
- tmp_storage_dir: '%kernel.root_dir%/../var/cache/tmp/pim/file_storage'
- upload_tmp_dir: '%kernel.root_dir%/../var/cache/tmp/pim/upload_tmp_dir'
- pim_ce_dev_src_folder_location: '%kernel.project_dir%'
-
-akeneo_storage_utils:
- mapping_overrides:
- -
- original: Akeneo\Pim\Structure\Component\Model\AttributeOption
- override: Flagbit\Bundle\TableAttributeBundle\Entity\AttributeOption
-
diff --git a/tests/Kernel/config/packages/test/ee-services.yml b/tests/Kernel/config/packages/test/ee-services.yml
new file mode 100644
index 0000000..c046729
--- /dev/null
+++ b/tests/Kernel/config/packages/test/ee-services.yml
@@ -0,0 +1,14 @@
+# Because an Open Source Akeneo project can't' install Enterprise dependencies
+# this service file is using placeholder to make enterprise features testable.
+services:
+ pimee_workflow.query.filter.product_proposal_registry:
+ class: '%pim_catalog.query.filter.registry.class%'
+ public: true
+ arguments:
+ - '@pim_catalog.repository.attribute'
+
+ pimee_workflow.query.filter.published_product_registry:
+ class: '%pim_catalog.query.filter.registry.class%'
+ public: true
+ arguments:
+ - '@pim_catalog.repository.attribute'
diff --git a/tests/Kernel/config/packages/test/imports.yml b/tests/Kernel/config/packages/test/imports.yml
new file mode 100644
index 0000000..82385b8
--- /dev/null
+++ b/tests/Kernel/config/packages/test/imports.yml
@@ -0,0 +1,61 @@
+# Imports every packages and packages/test YAML, except doctrine.yml and test/oneup_flysystem.yml
+imports:
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/akeneo_api.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/akeneo_batch.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/akeneo_elasticsearch.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/akeneo_pim_enrichment.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/akeneo_pim_user.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/akeneo_storage_utils.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/fos_auth_server.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/fos_js_routing.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/fos_rest.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/framework.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/test/framework.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/liip_imagine.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/oneup_flysystem.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/test_fake/oneup_flysystem.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/oro_filter.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/oro_translation.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/security.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/test/security.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/sensio_framework_extra.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/swiftmailer.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/twig.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/services/gedmo_doctrine_extensions.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/services/pim_parameters.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/services/services.yml' }
+ - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/services/pim.yml' }
+# - { resource: '../../../../../vendor/akeneo/pim-community-dev/config/packages/doctrine.yml' }
+
+doctrine:
+ dbal:
+ default_connection: default
+ connections:
+ default:
+ driver: 'pdo_mysql'
+ dbname: '%env(APP_DATABASE_NAME)%'
+ host: '%env(APP_DATABASE_HOST)%'
+ port: '%env(APP_DATABASE_PORT)%'
+ user: '%env(APP_DATABASE_USER)%'
+ password: '%env(APP_DATABASE_PASSWORD)%'
+ charset: utf8mb4
+ default_table_options:
+ charset: utf8mb4
+ collate: utf8mb4_unicode_ci
+ row_format: DYNAMIC
+ server_version: '8.0'
+ mapping_types:
+ json: string
+ types:
+ datetime: Akeneo\Tool\Bundle\StorageUtilsBundle\Doctrine\DBAL\Types\UTCDateTimeType
+ orm:
+ auto_generate_proxy_classes: '%kernel.debug%'
+ auto_mapping: true
+ resolve_target_entities:
+ placeholder: placeholder
+ mappings:
+ tree:
+ type: annotation
+ alias: Gedmo
+ prefix: Gedmo\Tree\Entity
+ dir: '%kernel.root_dir%/../../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity'
diff --git a/tests/Kernel/config/packages/test/tableattribute.yml b/tests/Kernel/config/packages/test/tableattribute.yml
new file mode 100644
index 0000000..ecaec7f
--- /dev/null
+++ b/tests/Kernel/config/packages/test/tableattribute.yml
@@ -0,0 +1,9 @@
+akeneo_storage_utils:
+ mapping_overrides:
+ -
+ original: Akeneo\Pim\Structure\Component\Model\AttributeOption
+ override: Flagbit\Bundle\TableAttributeBundle\Entity\AttributeOption
+
+
+parameters:
+ doctrine.default_entity_manager: default
diff --git a/tests/Kernel/config/parameters.yml b/tests/Kernel/config/parameters.yml
deleted file mode 100644
index d1ab4fe..0000000
--- a/tests/Kernel/config/parameters.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-parameters:
- database_driver: pdo_sqlite
- database_host: localhost
- database_port: ~
- database_name: akeneo_pim
- database_user: akeneo_pim
- database_password: akeneo_pim
- locale: en
- secret: ThisTokenIsNotSoSecretChangeIt
- product_index_name: akeneo_pim_product
- product_model_index_name: akeneo_pim_product_model
- product_and_product_model_index_name: akeneo_pim_product_and_product_model
- index_hosts: 'localhost: 9200'
diff --git a/tests/Kernel/config/pim.yml b/tests/Kernel/config/pim.yml
deleted file mode 100644
index c4504e4..0000000
--- a/tests/Kernel/config/pim.yml
+++ /dev/null
@@ -1,94 +0,0 @@
-imports:
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/akeneo_batch.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/akeneo_api.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/doctrine.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/fos_auth_server.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/fos_js_routing.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/fos_rest.yml' }
-# - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/gedmo_doctrine_extensions.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/liip_imagine.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/oneup_flysystem.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/oro_filter.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/oro_translation.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/pim_user.yml' }
- - { resource: '../../../vendor/akeneo/pim-community-dev/src/Akeneo/Platform/config/bundles/twig.yml' }
-
-# To have more details on the effect of this "pim_job_product_batch_size", on performances
-# memory leak, please have a look at this documentation part:
-# https://docs.akeneo.com/latest/technical_architecture/performances_guide/batch_page_size.html
-#
-# Note to the core developers:
-# The pim_job_product_batch_size has been changed from 100 to 10 at the beginning of 2018
-# already, because of fear of generating memory leak.
-# Now that we have more feedback, it seems to create more problem than real gain in term
-# of performances. Moreover this value was forced at 100 for our cloud customers, so this
-# was creating inconsistency in our installed base. So we are reverting it back to 100.
-#
-# So if you want to change it, do that only for major version and check with the tech team.
-#
-parameters:
- pim_job_product_batch_size: 100
-
-services:
- oro.cache.abstract:
- abstract: true
- class: Doctrine\Common\Cache\PhpFileCache
- arguments: ['%kernel.cache_dir%']
- twig.extension.intl:
- class: Twig_Extensions_Extension_Intl
- tags:
- - { name: twig.extension }
- doctrine.dbal.default.wrapped_connection:
- class: PDO
- factory: 'doctrine.dbal.session_connection:getWrappedConnection'
-
- session.handler.pdo:
- class: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
- arguments:
- - '@doctrine.dbal.default.wrapped_connection'
- -
- db_table: pim_session
- gedmo.listener.tree:
- class: Gedmo\Tree\TreeListener
- tags:
- - { name: doctrine.event_subscriber, connection: default }
- calls:
- - [ setAnnotationReader, [ '@annotation_reader' ] ]
-
-akeneo_pim_enrichment:
- localization:
- decimal_separators:
- - { value: '.', label: 'dot (.)' }
- - { value: ',', label: 'comma (,)' }
- - { value: '٫', label: 'arabic decimal separator (٫)' }
- date_formats:
- - { value: 'yyyy-MM-dd', label: 'yyyy-mm-dd' }
- - { value: 'yyyy/MM/dd', label: 'yyyy/mm/dd' }
- - { value: 'MM/dd/yyyy', label: 'mm/dd/yyyy' }
- - { value: 'dd/MM/yyyy', label: 'dd/mm/yyyy' }
- - { value: 'dd.MM.yyyy', label: 'dd.mm.yyyy' }
-
-akeneo_storage_utils:
- mapping_overrides: ~
-
-akeneo_elasticsearch:
- hosts: "%index_hosts%"
- indexes:
- -
- service_name: "akeneo_elasticsearch.client.product"
- index_name: "%product_index_name%"
- configuration_files: "%elasticsearch_index_configuration_files%"
- -
- service_name: "akeneo_elasticsearch.client.product_model"
- index_name: "%product_model_index_name%"
- configuration_files: "%elasticsearch_index_configuration_files%"
- -
- service_name: "akeneo_elasticsearch.client.product_and_product_model"
- index_name: "%product_and_product_model_index_name%"
- configuration_files: "%elasticsearch_index_configuration_files%"
-
-framework:
- cache:
- pools:
- name:
- adapter: cache.adapter.apcu
diff --git a/tests/Pim/PimTest.php b/tests/Pim/PimTest.php
index 423202f..3d3c1d5 100644
--- a/tests/Pim/PimTest.php
+++ b/tests/Pim/PimTest.php
@@ -2,16 +2,19 @@
namespace Flagbit\Bundle\TableAttributeBundle\Test\Pim;
-use Akeneo\Tool\Component\StorageUtils\Repository\IdentifiableObjectRepositoryInterface;
use Akeneo\Pim\Enrichment\Bundle\Elasticsearch\Filter\Attribute\OptionFilter;
-use Akeneo\Pim\Structure\Component\Model\Attribute;
use Akeneo\Pim\Enrichment\Component\Product\Comparator\Attribute\ScalarComparator;
+use Akeneo\Pim\Enrichment\Component\Product\Connector\ArrayConverter\FlatToStandard\ValueConverter\TextConverter as FlatToStandardTextConverter;
+use Akeneo\Pim\Enrichment\Component\Product\Connector\ArrayConverter\StandardToFlat\Product\ValueConverter\TextConverter as StandardToFlatTextConverter;
use Akeneo\Pim\Enrichment\Component\Product\Query\Filter\FilterRegistry;
-use Akeneo\Pim\Structure\Component\Repository\AttributeRepositoryInterface;
use Akeneo\Pim\Enrichment\Component\Product\Updater\Setter\AttributeSetter;
use Akeneo\Pim\Enrichment\Component\Product\Value\ScalarValue;
-use Akeneo\Pim\Enrichment\Component\Product\Connector\ArrayConverter\FlatToStandard\ValueConverter\TextConverter as FlatToStandardTextConverter;
-use Akeneo\Pim\Enrichment\Component\Product\Connector\ArrayConverter\StandardToFlat\Product\ValueConverter\TextConverter as StandardToFlatTextConverter;
+use Akeneo\Pim\Structure\Component\Model\Attribute;
+use Akeneo\Pim\Structure\Component\Query\PublicApi\AttributeType\Attribute as PublicApiAttribute;
+use Akeneo\Pim\Structure\Component\Repository\AttributeRepositoryInterface;
+use Akeneo\Tool\Component\StorageUtils\Repository\IdentifiableObjectRepositoryInterface;
+use Flagbit\Bundle\TableAttributeBundle\AttributeType\TableType;
+use Flagbit\Bundle\TableAttributeBundle\Component\Product\Factory\Value\TableValueFactory;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
class PimTest extends KernelTestCase
@@ -20,7 +23,7 @@ class PimTest extends KernelTestCase
public function testFlatToStandardConverterRegisters()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$registryValueConverter = $container->get('pim_connector.array_converter.flat_to_standard.product.value_converter.registry');
@@ -32,7 +35,7 @@ public function testFlatToStandardConverterRegisters()
public function testStandardToFlatConverterRegisters()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$registryValueConverter = $container->get('pim_connector.array_converter.standard_to_flat.product.value_converter.registry');
@@ -47,7 +50,7 @@ public function testStandardToFlatConverterRegisters()
public function testAttributeComparedSuccessfully()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$registryComparator = $container->get('pim_catalog.comparator.registry');
@@ -59,25 +62,31 @@ public function testAttributeComparedSuccessfully()
public function testScalarValueCreated()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
- $valueFactory = $container->get('pim_catalog.factory.value');
+ $valueFactory = $container->get('akeneo.pim.enrichment.factory.value');
- $attribute = new Attribute();
- $attribute->setAttributeType('flagbit_catalog_table');
- $attribute->setLocalizable(false);
- $attribute->setScopable(false);
- $attribute->setCode('foo');
+ $attribute = new PublicApiAttribute(
+ 'foo',
+ 'flagbit_catalog_table',
+ [],
+ false,
+ false,
+ null,
+ null,
+ 'flagbit_catalog_table',
+ []
+ );
- $value = $valueFactory->create($attribute, null, null, '{}');
+ $value = $valueFactory->createWithoutCheckingData($attribute, null, null, '{}');
- self::assertInstanceOf(ScalarValue::class, $value);
+ self::assertEquals(ScalarValue::value('foo', '{}'), $value);
}
public function testProductUpdatedSuccessfully()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$repository = $this->createMock(IdentifiableObjectRepositoryInterface::class);
@@ -93,13 +102,57 @@ public function testProductUpdatedSuccessfully()
self::assertInstanceOf(AttributeSetter::class, $updater);
}
+ public function testSupportsTableMaskItem()
+ {
+ self::bootKernel();
+ $container = self::$container;
+
+ $maskItemGenerator = $container->get('akeneo.pim.enrichment.completeness.mask_item_generator.generator');
+
+ $tableMask = $maskItemGenerator->generate('code', TableType::FLAGBIT_CATALOG_TABLE, 'channel', 'locale', 'value');
+
+ self::assertSame(['code-channel-locale'], $tableMask);
+ }
+
+ public function testSupportsTableValueFactory()
+ {
+ self::bootKernel();
+ $container = self::$container;
+
+ $attribute = new PublicApiAttribute(
+ 'foo',
+ 'flagbit_catalog_table',
+ [],
+ false,
+ false,
+ null,
+ null,
+ 'flagbit_catalog_table',
+ []
+ );
+
+ $valueFactory = $container->get('akeneo.pim.enrichment.factory.value');
+
+ $tableValue = $valueFactory->createByCheckingData($attribute, null, null, '{}');
+
+ self::assertInstanceOf(ScalarValue::class, $tableValue);
+ self::assertSame('foo', $tableValue->getAttributeCode());
+ self::assertSame('{}', $tableValue->getData());
+
+ $tableValue = $valueFactory->createWithoutCheckingData($attribute, null, null, '{}');
+
+ self::assertInstanceOf(ScalarValue::class, $tableValue);
+ self::assertSame('foo', $tableValue->getAttributeCode());
+ self::assertSame('{}', $tableValue->getData());
+ }
+
/**
* @dataProvider queryBuildersProvider
*/
public function testQueryBuilderFiltersCorrectly($operator, $service)
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$attribute = new Attribute();
$attribute->setType('flagbit_catalog_table');
@@ -119,6 +172,25 @@ public function testQueryBuilderFiltersCorrectly($operator, $service)
self::assertInstanceOf(OptionFilter::class, $filter);
}
+ /**
+ * @dataProvider queryBuildersProvider
+ */
+ public function testQueryBuilderAttributeFiltersCorrectly($operator, $service)
+ {
+ self::bootKernel();
+ $container = self::$container;
+
+ $attribute = new Attribute();
+ $attribute->setType('flagbit_catalog_table');
+
+ /** @var FilterRegistry $filterRegistry */
+ $filterRegistry = $container->get($service);
+
+ $filter = $filterRegistry->getAttributeFilter($attribute, $operator);
+
+ self::assertInstanceOf(OptionFilter::class, $filter);
+ }
+
public function queryBuildersProvider()
{
return [
@@ -134,6 +206,16 @@ public function queryBuildersProvider()
['EMPTY', 'pim_catalog.query.filter.product_and_product_model_registry'],
['NOT EMPTY', 'pim_catalog.query.filter.product_and_product_model_registry'],
['NOT IN', 'pim_catalog.query.filter.product_and_product_model_registry'],
+ // service doesn't exist in community. See tests/Kernel/config/packages/test/ee-services.yml
+ ['IN', 'pimee_workflow.query.filter.product_proposal_registry'],
+ ['EMPTY', 'pimee_workflow.query.filter.product_proposal_registry'],
+ ['NOT EMPTY', 'pimee_workflow.query.filter.product_proposal_registry'],
+ ['NOT IN', 'pimee_workflow.query.filter.product_proposal_registry'],
+ // service doesn't exist in community. See tests/Kernel/config/packages/test/ee-services.yml
+ ['IN', 'pimee_workflow.query.filter.published_product_registry'],
+ ['EMPTY', 'pimee_workflow.query.filter.published_product_registry'],
+ ['NOT EMPTY', 'pimee_workflow.query.filter.published_product_registry'],
+ ['NOT IN', 'pimee_workflow.query.filter.published_product_registry'],
];
}
}
diff --git a/tests/Provider/Field/TableFieldProviderTest.php b/tests/Provider/Field/TableFieldProviderTest.php
index d489da7..6659172 100644
--- a/tests/Provider/Field/TableFieldProviderTest.php
+++ b/tests/Provider/Field/TableFieldProviderTest.php
@@ -10,7 +10,7 @@ class TableFieldProviderTest extends KernelTestCase
public function testFieldProviderIsCompatible()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$chainedFieldProvider = $container->get('pim_enrich.provider.field.chained');
diff --git a/tests/Validator/ConstraintGuesser/TableGuesserTest.php b/tests/Validator/ConstraintGuesser/TableGuesserTest.php
index 0dcb474..bc6468e 100644
--- a/tests/Validator/ConstraintGuesser/TableGuesserTest.php
+++ b/tests/Validator/ConstraintGuesser/TableGuesserTest.php
@@ -11,7 +11,7 @@ class TableGuesserTest extends KernelTestCase
public function testTableGuesserIsTaggedCorrectly()
{
self::bootKernel();
- $container = self::$kernel->getContainer();
+ $container = self::$container;
$chainedAttributeConstraintGuesser = $container->get('pim_catalog.validator.constraint_guesser.chained_attribute');
diff --git a/tests/web/.gitkeep b/tests/public/.gitkeep
similarity index 100%
rename from tests/web/.gitkeep
rename to tests/public/.gitkeep