1 | <?php |
||
34 | class SchematicTest extends BaseTest |
||
35 | { |
||
36 | /** |
||
37 | * @var Schematic |
||
38 | */ |
||
39 | private $schematicService; |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | public function setUp() |
||
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | private function getYamlTestFile() |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | private function getYamlExportFile() |
||
65 | |||
66 | /** |
||
67 | * @param string $handle |
||
68 | * @param Mock $mock |
||
69 | */ |
||
70 | private function setCraftComponent($handle, Mock $mock) |
||
74 | |||
75 | /** |
||
76 | * @return Mock|FieldsService |
||
77 | */ |
||
78 | public function getMockFieldsService() |
||
88 | |||
89 | /** |
||
90 | * @param string $class |
||
91 | * @param string $method |
||
92 | * @param Invocation $invocation |
||
93 | * @param mixed $returnValue |
||
94 | * |
||
95 | * @return Mock |
||
96 | */ |
||
97 | public function getDynamicallyMockedService($class, $method, Invocation $invocation, $returnValue) |
||
105 | |||
106 | /** |
||
107 | * @return Mock|GlobalsService |
||
108 | */ |
||
109 | public function getMockGlobalsService() |
||
119 | |||
120 | /** |
||
121 | * @return Mock|SectionsService |
||
122 | */ |
||
123 | public function getMockSectionsService() |
||
133 | |||
134 | /** |
||
135 | * @return Mock|Result |
||
136 | */ |
||
137 | public function getMockResultModel() |
||
145 | |||
146 | /** |
||
147 | * Creates mock for service. |
||
148 | * |
||
149 | * @param string $service |
||
150 | * @param string $handle |
||
151 | */ |
||
152 | private function createMockService($service, $handle) |
||
163 | |||
164 | /** |
||
165 | * @return Base|Mock |
||
166 | */ |
||
167 | public function getMockAbstractService() |
||
176 | |||
177 | /** |
||
178 | * @return PluginsService|Mock |
||
179 | */ |
||
180 | public function getMockPluginsService() |
||
194 | |||
195 | /** |
||
196 | * @return Mock|AssetSourcesService |
||
197 | */ |
||
198 | public function getMockAssetSourcesService() |
||
208 | |||
209 | /** |
||
210 | * @return Mock|AssetTransformsService |
||
211 | */ |
||
212 | public function getMockAssetTransformsService() |
||
222 | |||
223 | /** |
||
224 | * @return Mock|CategoriesService |
||
225 | */ |
||
226 | public function getMockCategoriesService() |
||
236 | |||
237 | /** |
||
238 | * @return Mock|TagsService |
||
239 | */ |
||
240 | public function getMockTagsService() |
||
250 | |||
251 | /** |
||
252 | * Mock all required services. |
||
253 | */ |
||
254 | private function mockServices() |
||
255 | { |
||
256 | $this->createMockService(Locales::class, 'schematic_locales'); |
||
257 | $this->createMockService(AssetSources::class, 'schematic_assetSources'); |
||
258 | $this->createMockService(AssetTransforms::class, 'schematic_assetTransforms'); |
||
259 | $this->createMockService(Fields::class, 'schematic_fields'); |
||
260 | $this->createMockService(GlobalSets::class, 'schematic_globalSets'); |
||
261 | $this->createMockService(Plugins::class, 'schematic_plugins'); |
||
262 | $this->createMockService(Sections::class, 'schematic_sections'); |
||
263 | $this->createMockService(UserGroups::class, 'schematic_userGroups'); |
||
264 | $this->createMockService(Users::class, 'schematic_users'); |
||
265 | $this->createMockService(CategoryGroups::class, 'schematic_categoryGroups'); |
||
266 | $this->createMockService(TagGroups::class, 'schematic_tagGroups'); |
||
267 | $this->createMockService(ElementIndexSettings::class, 'schematic_elementIndexSettings'); |
||
268 | |||
269 | $mockPluginsService = $this->getMockPluginsService(); |
||
270 | $this->setCraftComponent('plugins', $mockPluginsService); |
||
271 | } |
||
272 | |||
273 | /** |
||
274 | * Test import from Yaml. |
||
275 | * |
||
276 | * @covers ::importFromYaml |
||
277 | */ |
||
278 | public function testImportFromYamlWithForce() |
||
283 | |||
284 | /** |
||
285 | * @param $service |
||
286 | * |
||
287 | * @return Mock |
||
288 | */ |
||
289 | private function getMockAllGroupsMethodService($service) |
||
293 | |||
294 | /** |
||
295 | * Prep export services. |
||
296 | */ |
||
297 | private function prepExportMockServices() |
||
326 | |||
327 | /** |
||
328 | * Test export to yml. |
||
329 | * |
||
330 | * @covers ::exportToYaml |
||
331 | */ |
||
332 | public function testExportFromYaml() |
||
339 | |||
340 | /** |
||
341 | * Test export to yml excluding data types. |
||
342 | * |
||
343 | * @covers ::exportToYaml |
||
344 | */ |
||
345 | public function testExportToYamlExcludingDataTypes() |
||
363 | |||
364 | /** |
||
365 | * Test export to yml with error writing to file. |
||
366 | * |
||
367 | * @covers ::exportToYaml |
||
368 | */ |
||
369 | public function testExportFromYamlWithFileError() |
||
376 | } |
||
377 |