1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Setono\SyliusSchedulerPlugin\Fixture; |
||
6 | |||
7 | use Setono\SyliusSchedulerPlugin\Model\Job; |
||
8 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||
9 | use Webmozart\Assert\Assert; |
||
10 | |||
11 | final class JobFixture extends AbstractResourceFixture |
||
12 | { |
||
13 | /** |
||
14 | * @return string |
||
15 | */ |
||
16 | public function getName(): string |
||
17 | { |
||
18 | return 'setono_scheduler_job'; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * {@inheritdoc} |
||
23 | */ |
||
24 | protected function configureResourceNode(ArrayNodeDefinition $resourceNode): void |
||
25 | { |
||
26 | $resourceNode |
||
27 | ->children() |
||
28 | ->scalarNode('schedule')->cannotBeEmpty()->end() |
||
29 | ->scalarNode('command')->cannotBeEmpty()->end() |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
30 | ->arrayNode('args') |
||
31 | ->requiresAtLeastOneElement() |
||
32 | ->treatNullLike([]) |
||
33 | ->beforeNormalization()->castToArray()->end() |
||
34 | ->scalarPrototype()->cannotBeEmpty()->end() |
||
35 | ->end() |
||
36 | ->scalarNode('state') |
||
37 | ->beforeNormalization() |
||
38 | ->ifString() |
||
39 | ->then(function (string $value) { |
||
40 | Assert::oneOf($value, Job::getStates(), sprintf( |
||
41 | 'Invalid state provided: %s. Expected one of: %s', |
||
42 | $value, |
||
43 | implode(', ', Job::getStates()) |
||
44 | )); |
||
45 | |||
46 | return $value; |
||
47 | }) |
||
48 | ->end() |
||
49 | ->cannotBeEmpty() |
||
50 | ->end() |
||
51 | ->scalarNode('queue')->cannotBeEmpty()->end() |
||
52 | ->scalarNode('priority')->cannotBeEmpty()->end() |
||
53 | // ->scalarNode('created_at')->cannotBeEmpty()->end() |
||
54 | // ->scalarNode('started_at')->cannotBeEmpty()->end() |
||
55 | // ->scalarNode('checked_at')->cannotBeEmpty()->end() |
||
56 | // ->scalarNode('closed_at')->cannotBeEmpty()->end() |
||
57 | ->scalarNode('execute_after')->cannotBeEmpty()->end() |
||
58 | // ->arrayNode('dependencies') |
||
59 | // ->defaultValue([]) |
||
60 | // ->requiresAtLeastOneElement() |
||
61 | // ->treatNullLike([]) |
||
62 | // ->beforeNormalization() |
||
63 | // ->ifTrue(function ($values){ |
||
64 | // return !empty($values); |
||
65 | // }) |
||
66 | // ->then(function(){ |
||
67 | // throw new NotImplementedException(sprintf( |
||
68 | // 'Providing "dependencies" at %s fixture not yet implemented', |
||
69 | // $this->getName() |
||
70 | // )); |
||
71 | // }) |
||
72 | // ->end() |
||
73 | // ->beforeNormalization()->castToArray()->end() |
||
74 | // ->scalarPrototype()->cannotBeEmpty()->end() |
||
75 | // ->end() |
||
76 | ->scalarNode('worker_name')->cannotBeEmpty()->end() |
||
77 | ->scalarNode('output')->cannotBeEmpty()->end() |
||
78 | ->scalarNode('error_output')->cannotBeEmpty()->end() |
||
79 | ->scalarNode('exit_code')->cannotBeEmpty()->end() |
||
80 | ->scalarNode('max_runtime')->cannotBeEmpty()->end() |
||
81 | ->scalarNode('max_retries')->cannotBeEmpty()->end() |
||
82 | // ->scalarNode('original_job') |
||
83 | // ->cannotBeEmpty() |
||
84 | // ->beforeNormalization() |
||
85 | // ->ifString() |
||
86 | // ->then(function(){ |
||
87 | // throw new NotImplementedException(sprintf( |
||
88 | // 'Providing "original_job" at %s fixture not yet implemented', |
||
89 | // $this->getName() |
||
90 | // )); |
||
91 | // }) |
||
92 | // ->end() |
||
93 | // ->end() |
||
94 | ->scalarNode('retry_jobs')->cannotBeEmpty()->end() |
||
95 | ->end() |
||
96 | ; |
||
97 | } |
||
98 | } |
||
99 |