Completed
Pull Request — master (#552)
by Greg
03:19
created

RunnerTest::testSettingConfigurationFromCommandOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
use Robo\Robo;
3
4
use Robo\Config\YamlConfigLoader;
5
6
class RunnerTest extends \Codeception\TestCase\Test
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    /**
9
     * @var \Robo\Runner
10
     */
11
    private $runner;
12
13
    /**
14
     * @var \CodeGuy
15
     */
16
    protected $guy;
17
18
    public function _before()
19
    {
20
        $this->runner = new \Robo\Runner('\Robo\RoboFileFixture');
21
    }
22
23
    public function testHandleError()
24
    {
25
        $tmpLevel = error_reporting();
26
27
        $this->assertFalse($this->runner->handleError());
28
        error_reporting(0);
29
        $this->assertTrue($this->runner->handleError());
30
31
        error_reporting($tmpLevel);
32
    }
33
34
    public function testErrorIsHandled()
35
    {
36
        $tmpLevel = error_reporting();
37
38
        // Set error_get_last to a known state.  Note that it can never be
39
        // reset; see http://php.net/manual/en/function.error-get-last.php
40
        @trigger_error('control');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
41
        $error_description = error_get_last();
42
        $this->assertEquals('control', $error_description['message']);
43
        @trigger_error('');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
44
        $error_description = error_get_last();
45
        $this->assertEquals('', $error_description['message']);
46
47
        // Set error_reporting to a non-zero value.  In this instance,
48
        // 'trigger_error' would abort our test script, so we use
49
        // @trigger_error so that execution will continue.  With our
50
        // error handler in place, the value of error_get_last() does
51
        // not change.
52
        error_reporting(E_USER_ERROR);
53
        set_error_handler(array($this->runner, 'handleError'));
54
        @trigger_error('test error', E_USER_ERROR);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
55
        $error_description = error_get_last();
56
        $this->assertEquals('', $error_description['message']);
57
58
        // Set error_reporting to zero.  Now, even 'trigger_error'
59
        // does not abort execution.  The value of error_get_last()
60
        // still does not change.
61
        error_reporting(0);
62
        trigger_error('test error 2', E_USER_ERROR);
63
        $error_description = error_get_last();
64
        $this->assertEquals('', $error_description['message']);
65
66
        error_reporting($tmpLevel);
67
    }
68
69
    public function testThrowsExceptionWhenNoContainerAvailable()
70
    {
71
        \PHPUnit_Framework_TestCase::setExpectedExceptionRegExp(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCa...pectedExceptionRegExp() has been deprecated with message: Method deprecated since Release 5.6.0; use expectExceptionMessageRegExp() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
72
            '\RuntimeException',
73
            '/container is not initialized yet.*/'
74
        );
75
        Robo::unsetContainer();
76
        Robo::getContainer();
77
    }
78
79
    public function testRunnerNoSuchCommand()
80
    {
81
        $argv = ['placeholder', 'no-such-command'];
82
        $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
83
        $this->guy->seeInOutput('Command "no-such-command" is not defined.');
84
    }
85
86
    public function testRunnerList()
87
    {
88
        $argv = ['placeholder', 'list'];
89
        $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
90
        $this->guy->seeInOutput('test:array-args');
91
    }
92
93
    public function testRunnerTryArgs()
94
    {
95
        $argv = ['placeholder', 'test:array-args', 'a', 'b', 'c'];
96
        $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
97
98
        $expected = <<<EOT
99
>  The parameters passed are:
100
array (
101
  0 => 'a',
102
  1 => 'b',
103
  2 => 'c',
104
)
105
106
EOT;
107
        $this->guy->seeOutputEquals($expected);
108
    }
109
110
    public function testSymfonyStyle()
111
    {
112
        $argv = ['placeholder', 'test:symfony-style'];
113
        $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
114
        $this->guy->seeInOutput('Some text in section one.');
115
    }
116
117 View Code Duplication
    public function testCommandEventHook()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
    {
119
        $argv = ['placeholder', 'test:command-event'];
120
        $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
121
122
        $expected = <<<EOT
123
 This is the command-event hook for the test:command-event command.
124
 This is the main method for the test:command-event command.
125
 This is the post-command hook for the test:command-event command.
126
EOT;
127
        $this->guy->seeInOutput($expected);
128
    }
129
130 View Code Duplication
    public function testCustomEventHook()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
131
    {
132
        $argv = ['placeholder', 'test:custom-event'];
133
        $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
134
135
        $expected = 'one,two';
136
        $this->guy->seeInOutput($expected);
137
    }
138
139
    public function testRoboStaticRunMethod()
140
    {
141
        $argv = ['placeholder', 'test:symfony-style'];
142
        $commandFiles = ['\Robo\RoboFileFixture'];
143
        Robo::run($argv, $commandFiles, 'MyApp', '1.2.3', $this->guy->capturedOutputStream());
0 ignored issues
show
Documentation introduced by
$commandFiles is of type array<integer,string,{"0":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
144
        $this->guy->seeInOutput('Some text in section one.');
145
    }
146
147 View Code Duplication
    public function testDeploy()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
148
    {
149
        $argv = ['placeholder', 'test:deploy', '--simulate'];
150
        $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
151
        $this->guy->seeInOutput('[Simulator] Simulating Remote\\Ssh(\'mysite.com\', null)');
152
        $this->guy->seeInOutput('[Simulator] Running ssh mysite.com \'cd "/var/www/somesite" && git pull\'');
153
    }
154
155 View Code Duplication
    public function testRunnerTryError()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
156
    {
157
        $argv = ['placeholder', 'test:error'];
158
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
159
160
        $this->guy->seeInOutput('[Exec] Running ls xyzzy');
161
        $this->assertTrue($result > 0);
162
    }
163
164 View Code Duplication
    public function testRunnerTrySimulatedError()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
165
    {
166
        $argv = ['placeholder', 'test:error', '--simulate'];
167
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
168
169
        $this->guy->seeInOutput('Simulating Exec');
170
        $this->assertEquals(0, $result);
171
    }
172
173 View Code Duplication
    public function testRunnerTryException()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
174
    {
175
        $argv = ['placeholder', 'test:exception', '--task'];
176
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
177
178
        $this->guy->seeInOutput('Task failed with an exception');
179
        $this->assertEquals(1, $result);
180
    }
181
182
    public function testInitCommand()
183
    {
184
        $container = \Robo\Robo::getContainer();
185
        $app = $container->get('application');
186
        $app->addInitRoboFileCommand(getcwd() . '/testRoboFile.php', 'RoboTestClass');
187
188
        $argv = ['placeholder', 'init'];
189
        $status = $this->runner->run($argv, $this->guy->capturedOutputStream(), $app);
0 ignored issues
show
Documentation introduced by
$argv is of type array<integer,string,{"0":"string","1":"string"}>, but the function expects a null|object<Symfony\Comp...e\Input\InputInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
190
        $this->guy->seeInOutput('testRoboFile.php will be created in the current directory');
191
        $this->assertEquals(0, $status);
192
193
        $this->assertTrue(file_exists('testRoboFile.php'));
194
        $commandContents = file_get_contents('testRoboFile.php');
195
        unlink('testRoboFile.php');
196
        $this->assertContains('class RoboTestClass', $commandContents);
197
    }
198
199 View Code Duplication
    public function testTasksStopOnFail()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
200
    {
201
        $argv = ['placeholder', 'test:stop-on-fail'];
202
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
203
204
        $this->guy->seeInOutput('[');
205
        $this->assertTrue($result > 0);
206
    }
207
208 View Code Duplication
    public function testInvalidRoboDirectory()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
209
    {
210
        $runnerWithNoRoboFile = new \Robo\Runner();
211
212
        $argv = ['placeholder', 'list', '-f', 'no-such-directory'];
213
        $result = $runnerWithNoRoboFile->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
214
215
        $this->guy->seeInOutput('Path `no-such-directory` is invalid; please provide a valid absolute path to the Robofile to load.');
216
    }
217
218 View Code Duplication
    public function testUnloadableRoboFile()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
219
    {
220
        $runnerWithNoRoboFile = new \Robo\Runner();
221
222
        $argv = ['placeholder', 'list', '-f', dirname(__DIR__) . '/src/RoboFileFixture.php'];
223
        $result = $runnerWithNoRoboFile->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
224
225
        // We cannot load RoboFileFixture.php via -f / --load-from because
226
        // it has a namespace, and --load-from does not support that.
227
        $this->guy->seeInOutput('Class RoboFileFixture was not loaded');
228
    }
229
230 View Code Duplication
    public function testRunnerQuietOutput()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
231
    {
232
        $argv = ['placeholder', 'test:verbosity', '--quiet'];
233
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
234
235
        $this->guy->doNotSeeInOutput('This command will print more information at higher verbosity levels');
236
        $this->guy->doNotSeeInOutput('This is a verbose message (-v).');
237
        $this->guy->doNotSeeInOutput('This is a very verbose message (-vv).');
238
        $this->guy->doNotSeeInOutput('This is a debug message (-vvv).');
239
        $this->guy->doNotSeeInOutput(' [warning] This is a warning log message.');
240
        $this->guy->doNotSeeInOutput(' [notice] This is a notice log message.');
241
        $this->guy->doNotSeeInOutput(' [debug] This is a debug log message.');
242
        $this->assertEquals(0, $result);
243
    }
244
245 View Code Duplication
    public function testRunnerVerboseOutput()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
246
    {
247
        $argv = ['placeholder', 'test:verbosity', '-v'];
248
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
249
250
        $this->guy->seeInOutput('This command will print more information at higher verbosity levels');
251
        $this->guy->seeInOutput('This is a verbose message (-v).');
252
        $this->guy->doNotSeeInOutput('This is a very verbose message (-vv).');
253
        $this->guy->doNotSeeInOutput('This is a debug message (-vvv).');
254
        $this->guy->seeInOutput(' [warning] This is a warning log message.');
255
        $this->guy->seeInOutput(' [notice] This is a notice log message.');
256
        $this->guy->doNotSeeInOutput(' [debug] This is a debug log message.');
257
        $this->assertEquals(0, $result);
258
    }
259
260 View Code Duplication
    public function testRunnerVeryVerboseOutput()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
261
    {
262
        $argv = ['placeholder', 'test:verbosity', '-vv'];
263
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
264
265
        $this->guy->seeInOutput('This command will print more information at higher verbosity levels');
266
        $this->guy->seeInOutput('This is a verbose message (-v).');
267
        $this->guy->seeInOutput('This is a very verbose message (-vv).');
268
        $this->guy->doNotSeeInOutput('This is a debug message (-vvv).');
269
        $this->guy->seeInOutput(' [warning] This is a warning log message.');
270
        $this->guy->seeInOutput(' [notice] This is a notice log message.');
271
        $this->guy->doNotSeeInOutput(' [debug] This is a debug log message.');
272
        $this->assertEquals(0, $result);
273
    }
274
275 View Code Duplication
    public function testRunnerVerbosityThresholdVerbose()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
276
    {
277
        $argv = ['placeholder', 'test:verbosity-threshold', '-v'];
278
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
279
280
        $this->guy->seeInOutput('This command will print more information at higher verbosity levels');
281
        $this->guy->seeInOutput("Running echo verbose or higher\nverbose or higher");
282
        $this->guy->doNotSeeInOutput('very verbose or higher');
283
        $this->assertEquals(0, $result);
284
    }
285
286 View Code Duplication
    public function testRunnerVerbosityThresholdVeryVerbose()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
287
    {
288
        $argv = ['placeholder', 'test:verbosity-threshold', '-vv'];
289
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
290
291
        $this->guy->seeInOutput('This command will print more information at higher verbosity levels');
292
        $this->guy->seeInOutput("Running echo verbose or higher\nverbose or higher");
293
        $this->guy->seeInOutput("Running echo very verbose or higher\nvery verbose or higher");
294
        $this->assertEquals(0, $result);
295
    }
296
297 View Code Duplication
    public function testRunnerDebugOutput()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
298
    {
299
        $argv = ['placeholder', 'test:verbosity', '-vvv'];
300
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
301
302
        $this->guy->seeInOutput('This command will print more information at higher verbosity levels');
303
        $this->guy->seeInOutput('This is a verbose message (-v).');
304
        $this->guy->seeInOutput('This is a very verbose message (-vv).');
305
        $this->guy->seeInOutput('This is a debug message (-vvv).');
306
        $this->guy->seeInOutput(' [warning] This is a warning log message.');
307
        $this->guy->seeInOutput(' [notice] This is a notice log message.');
308
        $this->guy->seeInOutput(' [debug] This is a debug log message.');
309
        $this->assertEquals(0, $result);
310
    }
311
312 View Code Duplication
    public function testNoOptionsNoConfiguration()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
313
    {
314
        // Run without any config and without any options
315
        $argv = ['placeholder', 'test:simple-list'];
316
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
317
318
        $this->guy->seeInOutput("a: '1'");
319
        $this->guy->seeInOutput("b: '2'");
320
    }
321
322 View Code Duplication
    public function testOptionsButNoConfiguration()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
323
    {
324
        // Set one option, but provide no config
325
        $argv = ['placeholder', 'test:simple-list', '--b=3'];
326
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
327
328
        $this->guy->seeInOutput("a: '1'");
329
        $this->guy->seeInOutput("b: '3'");
330
    }
331
332 View Code Duplication
    public function testWithConfigurationButNoOptions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
333
    {
334
        \Robo\Robo::config()->set('command.test.simple-list.options.a', '4');
335
        \Robo\Robo::config()->set('command.test.simple-list.options.b', '5');
336
337
        $argv = ['placeholder', 'test:simple-list'];
338
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
339
340
        $this->guy->seeInOutput("a: '4'");
341
        $this->guy->seeInOutput("b: '5'");
342
    }
343
344 View Code Duplication
    public function testWithConfigurationAndOptionOverride()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
345
    {
346
        \Robo\Robo::config()->set('command.test.simple-list.options.a', '4');
347
        \Robo\Robo::config()->set('command.test.simple-list.options.b', '5');
348
349
        $argv = ['placeholder', 'test:simple-list', '--b=6'];
350
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
351
352
        $this->guy->seeInOutput("a: '4'");
353
        $this->guy->seeInOutput("b: '6'");
354
    }
355
356 View Code Duplication
    public function testSettingConfigurationFromCommandOptions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
357
    {
358
        $argv = ['placeholder', 'test:simple-list', '-D', 'config.key=value'];
359
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
360
361
        $this->guy->seeInOutput("a: '1'");
362
        $this->guy->seeInOutput("b: '2'");
363
364
        $actual = \Robo\Robo::config()->get('config.key');
365
        $this->assertEquals('value', $actual);
366
    }
367
368 View Code Duplication
    public function testWithConfigLoader()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
369
    {
370
        $loader = new YamlConfigLoader();
371
        $loader->load(dirname(__DIR__) . '/_data/robo.yml');
372
373
        \Robo\Robo::config()->extend($loader);
374
375
        $argv = ['placeholder', 'test:simple-list'];
376
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
377
378
        $this->guy->seeInOutput("a: '12'");
379
        $this->guy->seeInOutput("b: '13'");
380
    }
381
382
383 View Code Duplication
    public function testWithConfigLoaderAndCliOverride()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
384
    {
385
        $loader = new YamlConfigLoader();
386
        $loader->load(dirname(__DIR__) . '/_data/robo.yml');
387
388
        \Robo\Robo::config()->extend($loader);
389
390
        $argv = ['placeholder', 'test:simple-list', '--b=3'];
391
        $result = $this->runner->execute($argv, null, null, $this->guy->capturedOutputStream());
0 ignored issues
show
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
392
393
        $this->guy->seeInOutput("a: '12'");
394
        $this->guy->seeInOutput("b: '3'");
395
    }
396
}
397