1 | <?php |
||
25 | abstract class AbstractGeneratorControllerTest extends TestCase |
||
26 | { |
||
27 | use RequestTestTrait; |
||
28 | |||
29 | /** |
||
30 | * @param MockObject|StepResolverInterface $resolver |
||
31 | * @param MockObject|TranslatorInterface $translator |
||
32 | * @param MockObject|RouterInterface $router |
||
33 | * @param MockObject|ActionsRegistryInterface $actionsRegistry |
||
34 | * |
||
35 | * @return GeneratorController |
||
36 | */ |
||
37 | protected function createController( |
||
38 | StepResolverInterface $resolver = null, |
||
39 | RouterInterface $router = null, |
||
40 | TranslatorInterface $translator = null, |
||
41 | ActionsRegistryInterface $actionsRegistry = null |
||
42 | ): GeneratorController { |
||
43 | if (null === $resolver) { |
||
44 | $resolver = $this->createMock(StepResolverInterface::class); |
||
45 | } |
||
46 | if (null === $router) { |
||
47 | $router = $this->createMock(RouterInterface::class); |
||
48 | } |
||
49 | if (null === $translator) { |
||
50 | $translator = $this->createMock(TranslatorInterface::class); |
||
51 | } |
||
52 | if (null === $actionsRegistry) { |
||
53 | $actionsRegistry = $this->createMock(ActionsRegistryInterface::class); |
||
54 | } |
||
55 | |||
56 | return new GeneratorController($resolver, $actionsRegistry, $router, $translator); |
||
57 | } |
||
58 | |||
59 | protected function createManagerConfiguration(string $managerName, array $steps = []): array |
||
60 | { |
||
61 | $manager = [ |
||
62 | 'character_class' => CharacterStub::class, |
||
63 | 'steps' => [], |
||
64 | ]; |
||
65 | |||
66 | // Will be used to populate missing data |
||
67 | $baseStep = [ |
||
68 | 'action' => ConcreteAbstractActionStub::class, |
||
69 | 'label' => '', |
||
70 | 'number' => 1, |
||
71 | 'name' => '01', |
||
72 | 'manager_name' => $managerName, |
||
73 | 'dependencies' => [], |
||
74 | 'onchange_clear' => [], |
||
75 | ]; |
||
76 | |||
77 | $manager['steps'] = $steps ?: [ |
||
78 | '01' => $baseStep, |
||
79 | ]; |
||
80 | |||
81 | $i = 1; |
||
82 | foreach ($manager['steps'] as $name => &$step) { |
||
83 | $step = ['name' => $name, 'number' => $i++] + $step + $baseStep; |
||
84 | } |
||
85 | |||
86 | return $manager; |
||
87 | } |
||
88 | } |
||
89 |