1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace SlayerBirden\DFCodeGeneration; |
5
|
|
|
|
6
|
|
|
use Doctrine\Common\Annotations\AnnotationRegistry; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use SlayerBirden\DFCodeGeneration\Catalog\Entities\Product; |
9
|
|
|
use SlayerBirden\DFCodeGeneration\Generator\Config\StandardProvider; |
10
|
|
|
|
11
|
|
|
class ConfigProviderTest extends TestCase |
12
|
|
|
{ |
13
|
|
|
/** @var StandardProvider */ |
14
|
|
|
private $provider; |
15
|
|
|
|
16
|
|
|
protected function setUp() |
17
|
|
|
{ |
18
|
|
|
// This is required for annotations to work |
19
|
|
|
AnnotationRegistry::registerLoader('class_exists'); |
|
|
|
|
20
|
|
|
|
21
|
|
|
$this->provider = new StandardProvider(Product::class); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function testGetRouteFactoryName() |
25
|
|
|
{ |
26
|
|
|
$this->assertSame( |
27
|
|
|
'SlayerBirden\\DFCodeGeneration\\Catalog\\Factory\\ProductRoutesDelegator', |
28
|
|
|
$this->provider->getRouteFactoryName() |
29
|
|
|
); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testGetSpec() |
33
|
|
|
{ |
34
|
|
|
$expected = [ |
35
|
|
|
'name' => [ |
36
|
|
|
'required' => true, |
37
|
|
|
'filters' => [ |
38
|
|
|
[ |
39
|
|
|
'name' => 'stringtrim', |
40
|
|
|
] |
41
|
|
|
], |
42
|
|
|
'validators' => [ |
43
|
|
|
[ |
44
|
|
|
'name' => 'notempty', |
45
|
|
|
] |
46
|
|
|
], |
47
|
|
|
], |
48
|
|
|
'sku' => [ |
49
|
|
|
'required' => true, |
50
|
|
|
'filters' => [ |
51
|
|
|
[ |
52
|
|
|
'name' => 'stringtrim', |
53
|
|
|
] |
54
|
|
|
], |
55
|
|
|
'validators' => [ |
56
|
|
|
[ |
57
|
|
|
'name' => 'notempty', |
58
|
|
|
] |
59
|
|
|
], |
60
|
|
|
], |
61
|
|
|
]; |
62
|
|
|
|
63
|
|
|
$this->assertEquals($expected, $this->provider->getInputFilterSpec()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function testGetSpecName() |
67
|
|
|
{ |
68
|
|
|
$this->assertSame('ProductInputFilter', $this->provider->getInputFilterName()); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function testGetCurrentConfig() |
72
|
|
|
{ |
73
|
|
|
$this->assertEmpty($this->provider->getCurrentConfig()); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testGetConfigNameSpace() |
77
|
|
|
{ |
78
|
|
|
$this->assertEquals('SlayerBirden\\DFCodeGeneration\\Catalog', $this->provider->getConfigNameSpace()); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function testGetEntitiesSrc() |
82
|
|
|
{ |
83
|
|
|
$this->assertSame('src/Catalog/Entities', $this->provider->getEntitiesSrc()); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @dataProvider controllerNameProvider |
88
|
|
|
* |
89
|
|
|
* @param string $type |
90
|
|
|
* @param string $expected |
91
|
|
|
* @throws \ReflectionException |
92
|
|
|
*/ |
93
|
|
|
public function testGetControllerName(string $type, string $expected) |
94
|
|
|
{ |
95
|
|
|
$this->assertSame($expected, $this->provider->getControllerName($type)); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
public function controllerNameProvider(): array |
99
|
|
|
{ |
100
|
|
|
return [ |
101
|
|
|
[ |
102
|
|
|
'get', |
103
|
|
|
'SlayerBirden\\DFCodeGeneration\\Catalog\\Controller\\GetProductAction', |
104
|
|
|
], |
105
|
|
|
[ |
106
|
|
|
'gets', |
107
|
|
|
'SlayerBirden\\DFCodeGeneration\\Catalog\\Controller\\GetProductsAction', |
108
|
|
|
], |
109
|
|
|
[ |
110
|
|
|
'add', |
111
|
|
|
'SlayerBirden\\DFCodeGeneration\\Catalog\\Controller\\AddProductAction', |
112
|
|
|
], |
113
|
|
|
[ |
114
|
|
|
'update', |
115
|
|
|
'SlayerBirden\\DFCodeGeneration\\Catalog\\Controller\\UpdateProductAction', |
116
|
|
|
], |
117
|
|
|
[ |
118
|
|
|
'delete', |
119
|
|
|
'SlayerBirden\\DFCodeGeneration\\Catalog\\Controller\\DeleteProductAction', |
120
|
|
|
], |
121
|
|
|
]; |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.