|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Flagbit\Bundle\ProductClonerBundle\Test\Service; |
|
6
|
|
|
|
|
7
|
|
|
use Akeneo\Pim\Enrichment\Component\Product\Builder\ProductBuilderInterface; |
|
8
|
|
|
use Akeneo\Pim\Enrichment\Component\Product\Comparator\Filter\FilterInterface; |
|
9
|
|
|
use Akeneo\Pim\Enrichment\Component\Product\Converter\ConverterInterface; |
|
10
|
|
|
use Akeneo\Pim\Enrichment\Component\Product\Localization\Localizer\AttributeConverterInterface; |
|
11
|
|
|
use Akeneo\Pim\Enrichment\Component\Product\Repository\ProductModelRepositoryInterface; |
|
12
|
|
|
use Akeneo\Pim\Structure\Component\Repository\AttributeRepositoryInterface; |
|
13
|
|
|
use Akeneo\Tool\Component\StorageUtils\Factory\SimpleFactoryInterface; |
|
14
|
|
|
use Akeneo\Tool\Component\StorageUtils\Saver\SaverInterface; |
|
15
|
|
|
use Akeneo\Tool\Component\StorageUtils\Updater\ObjectUpdaterInterface; |
|
16
|
|
|
use Akeneo\UserManagement\Bundle\Context\UserContext; |
|
17
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; |
|
18
|
|
|
use Akeneo\Pim\Enrichment\Component\Product\Repository\ProductRepositoryInterface; |
|
19
|
|
|
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
|
20
|
|
|
use Symfony\Component\Validator\Validator\ValidatorInterface; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Test to ensure the services used by the bundle are available in the currently |
|
24
|
|
|
* used Akeneo version. This makes future updates easier, as this test can provide |
|
25
|
|
|
* a first indication if something critical may have changed. It does not replace manual |
|
26
|
|
|
* testing, as it only checks for service availability and not if the services undergone |
|
27
|
|
|
* a significant change. |
|
28
|
|
|
*/ |
|
29
|
|
|
class CheckUsedServicesTest extends KernelTestCase |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* Boot symfony kernel before executing any tests |
|
33
|
|
|
*/ |
|
34
|
|
|
protected function setUp(): void |
|
35
|
|
|
{ |
|
36
|
|
|
self::bootKernel(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @dataProvider usedServicesDataProvider |
|
41
|
|
|
* |
|
42
|
|
|
* @param string $serviceName |
|
43
|
|
|
* @param string $expectedType |
|
44
|
|
|
*/ |
|
45
|
|
|
public function testUsedServiceIsAvailable(string $serviceName, string $expectedType): void { |
|
46
|
|
|
self::assertTrue( |
|
47
|
|
|
static::$container->has($serviceName), |
|
48
|
|
|
sprintf('Service %s seems to not exist but is required by the bundle!', $serviceName) |
|
49
|
|
|
); |
|
50
|
|
|
self::assertInstanceOf( |
|
51
|
|
|
$expectedType, |
|
52
|
|
|
static::$container->get($serviceName), |
|
53
|
|
|
sprintf('Service %s must be an instance of %s!', $serviceName, $expectedType) |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return string[][] |
|
59
|
|
|
*/ |
|
60
|
|
|
public function usedServicesDataProvider(): array { |
|
61
|
|
|
return [ |
|
62
|
|
|
// Used in both places |
|
63
|
|
|
'Attribute Repository' => [ |
|
64
|
|
|
'pim_catalog.repository.attribute', |
|
65
|
|
|
AttributeRepositoryInterface::class |
|
66
|
|
|
], |
|
67
|
|
|
'External API Serializer' => [ |
|
68
|
|
|
'pim_external_api_serializer', |
|
69
|
|
|
NormalizerInterface::class |
|
70
|
|
|
], |
|
71
|
|
|
'Product Validator' => [ |
|
72
|
|
|
'pim_catalog.validator.product', |
|
73
|
|
|
ValidatorInterface::class |
|
74
|
|
|
], |
|
75
|
|
|
'Normalizer Violation' => [ |
|
76
|
|
|
'pim_enrich.normalizer.violation', |
|
77
|
|
|
NormalizerInterface::class |
|
78
|
|
|
], |
|
79
|
|
|
'Product Builder' => [ |
|
80
|
|
|
'pim_catalog.builder.product', |
|
81
|
|
|
ProductBuilderInterface::class |
|
82
|
|
|
], |
|
83
|
|
|
// Only used for product models |
|
84
|
|
|
'Product Model Repository' => [ |
|
85
|
|
|
'pim_catalog.repository.product_model', |
|
86
|
|
|
ProductModelRepositoryInterface::class |
|
87
|
|
|
], |
|
88
|
|
|
'Product Model Factory' => [ |
|
89
|
|
|
'pim_catalog.factory.product_model', |
|
90
|
|
|
SimpleFactoryInterface::class |
|
91
|
|
|
], |
|
92
|
|
|
'Product Model Updater' => [ |
|
93
|
|
|
'pim_catalog.updater.product_model', |
|
94
|
|
|
ObjectUpdaterInterface::class |
|
95
|
|
|
], |
|
96
|
|
|
'Product Model Saver' => [ |
|
97
|
|
|
'pim_catalog.saver.product_model', |
|
98
|
|
|
SaverInterface::class |
|
99
|
|
|
], |
|
100
|
|
|
// Only used for products |
|
101
|
|
|
'Product Repository' => [ |
|
102
|
|
|
'pim_catalog.repository.product', |
|
103
|
|
|
ProductRepositoryInterface::class |
|
104
|
|
|
], |
|
105
|
|
|
'Product Updater' => [ |
|
106
|
|
|
'pim_catalog.updater.product', |
|
107
|
|
|
ObjectUpdaterInterface::class |
|
108
|
|
|
], |
|
109
|
|
|
'Product Saver' => [ |
|
110
|
|
|
'pim_catalog.saver.product', |
|
111
|
|
|
SaverInterface::class |
|
112
|
|
|
], |
|
113
|
|
|
'User Context' => [ |
|
114
|
|
|
'pim_user.context.user', |
|
115
|
|
|
UserContext::class |
|
116
|
|
|
], |
|
117
|
|
|
'Localizer Converter' => [ |
|
118
|
|
|
'pim_catalog.localization.localizer.converter', |
|
119
|
|
|
AttributeConverterInterface::class |
|
120
|
|
|
], |
|
121
|
|
|
'Comparator Product Filter ' => [ |
|
122
|
|
|
'pim_catalog.comparator.filter.product', |
|
123
|
|
|
FilterInterface::class |
|
124
|
|
|
], |
|
125
|
|
|
'Enrich to Standard product Value Converter' => [ |
|
126
|
|
|
'pim_enrich.converter.enrich_to_standard.product_value', |
|
127
|
|
|
ConverterInterface::class |
|
128
|
|
|
], |
|
129
|
|
|
|
|
130
|
|
|
]; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|