Skip to content

Commit 926e3a3

Browse files
Rectorsimonschaufi
authored andcommitted
[TASK] Turn array return to yield in data providers
Applied rule: Rector\PHPUnit\CodeQuality\Rector\Class_\YieldDataProviderRector
1 parent 06c3d3b commit 926e3a3

File tree

13 files changed

+575
-617
lines changed

13 files changed

+575
-617
lines changed

tests/Unit/Application/Neos/FlowTest.php

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,32 +73,26 @@ public function registerComposerInstallTask(): void
7373
self::assertContains(InstallTask::class, $tasks['stage'][$this->subject->getName()]['update']['tasks']);
7474
}
7575

76-
public function commandPackageKeyProvider(): array
76+
public function commandPackageKeyProvider(): \Iterator
7777
{
78-
return [
79-
['1.0', 'typo3.flow3'],
80-
['2.0', 'typo3.flow'],
81-
['3.8', 'typo3.flow'],
82-
['4.0', 'neos.flow'],
83-
];
78+
yield ['1.0', 'typo3.flow3'];
79+
yield ['2.0', 'typo3.flow'];
80+
yield ['3.8', 'typo3.flow'];
81+
yield ['4.0', 'neos.flow'];
8482
}
8583

86-
public function flowScriptNameProvider(): array
84+
public function flowScriptNameProvider(): \Iterator
8785
{
88-
return [
89-
['1.0', 'flow3'],
90-
['1.1', 'flow3'],
91-
['1.2', 'flow']
92-
];
86+
yield ['1.0', 'flow3'];
87+
yield ['1.1', 'flow3'];
88+
yield ['1.2', 'flow'];
9389
}
9490

95-
public function essentialsDirectoryNameProvider(): array
91+
public function essentialsDirectoryNameProvider(): \Iterator
9692
{
97-
return [
98-
['1.0', 'Common'],
99-
['1.1', 'Common'],
100-
['1.2', 'BuildEssentials']
101-
];
93+
yield ['1.0', 'Common'];
94+
yield ['1.1', 'Common'];
95+
yield ['1.2', 'BuildEssentials'];
10296
}
10397

10498
/**

tests/Unit/Cli/Symfony/Logger/ConsoleFormatterTest.php

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,41 +36,39 @@ public function format(array $record, string $expectedOutput): void
3636
self::assertSame($expectedOutput, $this->subject->format($record));
3737
}
3838

39-
public function records(): array
39+
public function records(): \Iterator
4040
{
41-
return [
41+
yield [
4242
[
43-
[
44-
'level' => Logger::ERROR,
45-
'extra' => [],
46-
'context' => []
47-
],
48-
"<error>%message%</error>\n"
43+
'level' => Logger::ERROR,
44+
'extra' => [],
45+
'context' => []
4946
],
47+
"<error>%message%</error>\n"
48+
];
49+
yield [
5050
[
51-
[
52-
'level' => Logger::NOTICE,
53-
'extra' => [],
54-
'context' => []
55-
],
56-
"<comment>%message%</comment>\n"
51+
'level' => Logger::NOTICE,
52+
'extra' => [],
53+
'context' => []
5754
],
55+
"<comment>%message%</comment>\n"
56+
];
57+
yield [
5858
[
59-
[
60-
'level' => Logger::INFO,
61-
'extra' => [],
62-
'context' => []
63-
],
64-
"<info>%message%</info>\n"
59+
'level' => Logger::INFO,
60+
'extra' => [],
61+
'context' => []
6562
],
63+
"<info>%message%</info>\n"
64+
];
65+
yield [
6666
[
67-
[
68-
'level' => Logger::DEBUG,
69-
'extra' => [],
70-
'context' => []
71-
],
72-
"<debug>%message%</debug>\n"
67+
'level' => Logger::DEBUG,
68+
'extra' => [],
69+
'context' => []
7370
],
71+
"<debug>%message%</debug>\n"
7472
];
7573
}
7674
}

tests/Unit/Domain/Model/Clock/SystemClockTest.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,21 @@ public function successFullyCreateTimestampFromFormat(string $format, string $ti
5252
self::assertSame($expected, $this->subject->createTimestampFromFormat($format, $time));
5353
}
5454

55-
public function validFormatCanBeConvertedToTimestamp(): array
55+
public function validFormatCanBeConvertedToTimestamp(): \Iterator
5656
{
57-
return [
58-
['YmdHis', date('YmdHis', 1535216980), 1535216980],
59-
];
57+
yield ['YmdHis', date('YmdHis', 1535216980), 1535216980];
6058
}
6159

62-
public function validStringCanBeConvertedToTimestamp(): array
60+
public function validStringCanBeConvertedToTimestamp(): \Iterator
6361
{
64-
return [
65-
['1 day ago', 1535216980],
66-
['2 days ago', 1535216980],
67-
['1 second ago', 1535216980],
68-
];
62+
yield ['1 day ago', 1535216980];
63+
yield ['2 days ago', 1535216980];
64+
yield ['1 second ago', 1535216980];
6965
}
7066

71-
public function invalidStringsCannotBeConvertedToTimestamp(): array
67+
public function invalidStringsCannotBeConvertedToTimestamp(): \Iterator
7268
{
73-
return [
74-
['2 apples ago'],
75-
['One second and half'],
76-
];
69+
yield ['2 apples ago'];
70+
yield ['One second and half'];
7771
}
7872
}

tests/Unit/Domain/Model/DeploymentTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,8 @@ public function deploymentContainsChangedRelativeProjectRootPathForApplicationRe
176176
);
177177
}
178178

179-
public function wrongDeploymentLockIdentifiersProvided(): array
179+
public function wrongDeploymentLockIdentifiersProvided(): \Iterator
180180
{
181-
return [
182-
[''],
183-
];
181+
yield [''];
184182
}
185183
}

tests/Unit/Domain/Model/RollbackWorkflowTest.php

Lines changed: 109 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -84,126 +84,124 @@ public function runFailsIfNoNodesAreConfigured(): void
8484
*
8585
* Tests a simple setup with one node and one application.
8686
*/
87-
public function globalTaskDefinitions(): array
87+
public function globalTaskDefinitions(): \Iterator
8888
{
89-
return [
89+
yield [
90+
'Just one global task in stage initialize',
91+
static fn (RollbackWorkflow $workflow, Application $application): callable => static function () use ($workflow): void {
92+
$workflow
93+
->addTask('typo3.surf:test:setup', RollbackWorkflowStage::STEP_01_INITIALIZE);
94+
},
9095
[
91-
'Just one global task in stage initialize',
92-
static fn (RollbackWorkflow $workflow, Application $application): callable => static function () use ($workflow): void {
93-
$workflow
94-
->addTask('typo3.surf:test:setup', RollbackWorkflowStage::STEP_01_INITIALIZE);
95-
},
9696
[
97-
[
98-
'task' => 'typo3.surf:test:setup',
99-
'node' => 'test1.example.com',
100-
'application' => 'Test application',
101-
'deployment' => 'Test rollback deployment',
102-
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
103-
'options' => []
104-
],
105-
[
106-
'task' => RollbackTask::class,
107-
'node' => 'test1.example.com',
108-
'application' => 'Test application',
109-
'deployment' => 'Test rollback deployment',
110-
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
111-
'options' => []
112-
]
97+
'task' => 'typo3.surf:test:setup',
98+
'node' => 'test1.example.com',
99+
'application' => 'Test application',
100+
'deployment' => 'Test rollback deployment',
101+
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
102+
'options' => []
103+
],
104+
[
105+
'task' => RollbackTask::class,
106+
'node' => 'test1.example.com',
107+
'application' => 'Test application',
108+
'deployment' => 'Test rollback deployment',
109+
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
110+
'options' => []
113111
]
114-
],
112+
]
113+
];
114+
yield [
115+
'Add multiple tasks with afterTask',
116+
fn (RollbackWorkflow $workflow, Application $application): callable => static function () use ($workflow): void {
117+
$workflow
118+
->addTask('typo3.surf:test:setup', RollbackWorkflowStage::STEP_01_INITIALIZE)
119+
->afterTask('typo3.surf:test:setup', ['typo3.surf:test:secondsetup', 'typo3.surf:test:thirdsetup'])
120+
->afterTask('typo3.surf:test:secondsetup', 'typo3.surf:test:finalize');
121+
},
115122
[
116-
'Add multiple tasks with afterTask',
117-
fn (RollbackWorkflow $workflow, Application $application): callable => static function () use ($workflow): void {
118-
$workflow
119-
->addTask('typo3.surf:test:setup', RollbackWorkflowStage::STEP_01_INITIALIZE)
120-
->afterTask('typo3.surf:test:setup', ['typo3.surf:test:secondsetup', 'typo3.surf:test:thirdsetup'])
121-
->afterTask('typo3.surf:test:secondsetup', 'typo3.surf:test:finalize');
122-
},
123123
[
124-
[
125-
'task' => 'typo3.surf:test:setup',
126-
'node' => 'test1.example.com',
127-
'application' => 'Test application',
128-
'deployment' => 'Test rollback deployment',
129-
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
130-
'options' => []
131-
],
132-
[
133-
'task' => 'typo3.surf:test:secondsetup',
134-
'node' => 'test1.example.com',
135-
'application' => 'Test application',
136-
'deployment' => 'Test rollback deployment',
137-
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
138-
'options' => []
139-
],
140-
[
141-
'task' => 'typo3.surf:test:finalize',
142-
'node' => 'test1.example.com',
143-
'application' => 'Test application',
144-
'deployment' => 'Test rollback deployment',
145-
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
146-
'options' => []
147-
],
148-
[
149-
'task' => 'typo3.surf:test:thirdsetup',
150-
'node' => 'test1.example.com',
151-
'application' => 'Test application',
152-
'deployment' => 'Test rollback deployment',
153-
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
154-
'options' => []
155-
],
156-
[
157-
'task' => RollbackTask::class,
158-
'node' => 'test1.example.com',
159-
'application' => 'Test application',
160-
'deployment' => 'Test rollback deployment',
161-
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
162-
'options' => []
163-
]
124+
'task' => 'typo3.surf:test:setup',
125+
'node' => 'test1.example.com',
126+
'application' => 'Test application',
127+
'deployment' => 'Test rollback deployment',
128+
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
129+
'options' => []
130+
],
131+
[
132+
'task' => 'typo3.surf:test:secondsetup',
133+
'node' => 'test1.example.com',
134+
'application' => 'Test application',
135+
'deployment' => 'Test rollback deployment',
136+
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
137+
'options' => []
138+
],
139+
[
140+
'task' => 'typo3.surf:test:finalize',
141+
'node' => 'test1.example.com',
142+
'application' => 'Test application',
143+
'deployment' => 'Test rollback deployment',
144+
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
145+
'options' => []
146+
],
147+
[
148+
'task' => 'typo3.surf:test:thirdsetup',
149+
'node' => 'test1.example.com',
150+
'application' => 'Test application',
151+
'deployment' => 'Test rollback deployment',
152+
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
153+
'options' => []
154+
],
155+
[
156+
'task' => RollbackTask::class,
157+
'node' => 'test1.example.com',
158+
'application' => 'Test application',
159+
'deployment' => 'Test rollback deployment',
160+
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
161+
'options' => []
164162
]
165-
],
163+
]
164+
];
165+
yield [
166+
'Tasks in different stages',
167+
static fn (RollbackWorkflow $workflow, Application $application): callable => static function () use ($workflow): void {
168+
$workflow
169+
->addTask('typo3.surf:test:setup', RollbackWorkflowStage::STEP_01_INITIALIZE)
170+
->addTask('typo3.surf:test:checkout', RollbackWorkflowStage::STEP_02_EXECUTE)
171+
->addTask('typo3.surf:test:symlink', RollbackWorkflowStage::STEP_03_CLEANUP);
172+
},
166173
[
167-
'Tasks in different stages',
168-
static fn (RollbackWorkflow $workflow, Application $application): callable => static function () use ($workflow): void {
169-
$workflow
170-
->addTask('typo3.surf:test:setup', RollbackWorkflowStage::STEP_01_INITIALIZE)
171-
->addTask('typo3.surf:test:checkout', RollbackWorkflowStage::STEP_02_EXECUTE)
172-
->addTask('typo3.surf:test:symlink', RollbackWorkflowStage::STEP_03_CLEANUP);
173-
},
174174
[
175-
[
176-
'task' => 'typo3.surf:test:setup',
177-
'node' => 'test1.example.com',
178-
'application' => 'Test application',
179-
'deployment' => 'Test rollback deployment',
180-
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
181-
'options' => []
182-
],
183-
[
184-
'task' => 'typo3.surf:test:checkout',
185-
'node' => 'test1.example.com',
186-
'application' => 'Test application',
187-
'deployment' => 'Test rollback deployment',
188-
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
189-
'options' => []
190-
],
191-
[
192-
'task' => RollbackTask::class,
193-
'node' => 'test1.example.com',
194-
'application' => 'Test application',
195-
'deployment' => 'Test rollback deployment',
196-
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
197-
'options' => []
198-
],
199-
[
200-
'task' => 'typo3.surf:test:symlink',
201-
'node' => 'test1.example.com',
202-
'application' => 'Test application',
203-
'deployment' => 'Test rollback deployment',
204-
'stage' => RollbackWorkflowStage::STEP_03_CLEANUP,
205-
'options' => []
206-
]
175+
'task' => 'typo3.surf:test:setup',
176+
'node' => 'test1.example.com',
177+
'application' => 'Test application',
178+
'deployment' => 'Test rollback deployment',
179+
'stage' => RollbackWorkflowStage::STEP_01_INITIALIZE,
180+
'options' => []
181+
],
182+
[
183+
'task' => 'typo3.surf:test:checkout',
184+
'node' => 'test1.example.com',
185+
'application' => 'Test application',
186+
'deployment' => 'Test rollback deployment',
187+
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
188+
'options' => []
189+
],
190+
[
191+
'task' => RollbackTask::class,
192+
'node' => 'test1.example.com',
193+
'application' => 'Test application',
194+
'deployment' => 'Test rollback deployment',
195+
'stage' => RollbackWorkflowStage::STEP_02_EXECUTE,
196+
'options' => []
197+
],
198+
[
199+
'task' => 'typo3.surf:test:symlink',
200+
'node' => 'test1.example.com',
201+
'application' => 'Test application',
202+
'deployment' => 'Test rollback deployment',
203+
'stage' => RollbackWorkflowStage::STEP_03_CLEANUP,
204+
'options' => []
207205
]
208206
]
209207
];

0 commit comments

Comments
 (0)