1
|
|
|
<?php |
2
|
|
|
use AspectMock\Test as test; |
3
|
|
|
|
4
|
|
|
use Robo\Traits\Common\AdjustQuotes; |
5
|
|
|
|
6
|
|
|
class GulpTest extends \Codeception\TestCase\Test |
7
|
|
|
{ |
8
|
|
|
use AdjustQuotes; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @var \AspectMock\Proxy\ClassProxy |
12
|
|
|
*/ |
13
|
|
|
protected $baseGulp; |
14
|
|
|
|
15
|
|
|
protected function _before() |
16
|
|
|
{ |
17
|
|
|
$this->baseGulp = test::double('Robo\Task\Gulp\Base', [ |
18
|
|
|
'output' => new \Symfony\Component\Console\Output\NullOutput() |
19
|
|
|
]); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
// tests |
23
|
|
|
public function testGulpGetCommand() |
24
|
|
|
{ |
25
|
|
|
$this->assertEquals( |
26
|
|
|
$this->adjustQuotes("gulp 'default'"), |
27
|
|
|
(new \Robo\Task\Gulp\Run('default','gulp'))->getCommand() |
28
|
|
|
); |
29
|
|
|
|
30
|
|
|
$this->assertEquals( |
31
|
|
|
$this->adjustQuotes("gulp 'another'"), |
32
|
|
|
(new \Robo\Task\Gulp\Run('another','gulp'))->getCommand() |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
$this->assertEquals( |
36
|
|
|
$this->adjustQuotes("gulp 'default' --silent"), |
37
|
|
|
(new \Robo\Task\Gulp\Run('default','gulp'))->silent()->getCommand() |
38
|
|
|
); |
39
|
|
|
|
40
|
|
|
$this->assertEquals( |
41
|
|
|
$this->adjustQuotes("gulp 'default' --no-color"), |
42
|
|
|
(new \Robo\Task\Gulp\Run('default','gulp'))->noColor()->getCommand() |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
$this->assertEquals( |
46
|
|
|
$this->adjustQuotes("gulp 'default' --color"), |
47
|
|
|
(new \Robo\Task\Gulp\Run('default','gulp'))->color()->getCommand() |
48
|
|
|
); |
49
|
|
|
|
50
|
|
|
$this->assertEquals( |
51
|
|
|
$this->adjustQuotes("gulp 'default' --tasks-simple"), |
52
|
|
|
(new \Robo\Task\Gulp\Run('default','gulp'))->simple()->getCommand() |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
View Code Duplication |
public function testGulpRun() |
|
|
|
|
57
|
|
|
{ |
58
|
|
|
$gulp = test::double('Robo\Task\Gulp\Run', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]); |
|
|
|
|
59
|
|
|
|
60
|
|
|
$task = (new \Robo\Task\Gulp\Run('default','gulp'))->simple(); |
61
|
|
|
$this->assertEquals( |
62
|
|
|
$this->adjustQuotes("gulp 'default' --tasks-simple"), |
63
|
|
|
$task->getCommand()); |
64
|
|
|
$task->run(); |
65
|
|
|
$gulp->verifyInvoked('executeCommand', [$this->adjustQuotes("gulp 'default' --tasks-simple")]); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function testGulpUnusualChars() |
69
|
|
|
{ |
70
|
|
|
$isWindows = defined('PHP_WINDOWS_VERSION_MAJOR'); |
71
|
|
|
$expected = $isWindows ? |
72
|
|
|
'gulp "anotherWith weired!(\"\') Chars"' : |
73
|
|
|
"gulp 'anotherWith weired!(\"'\\'') Chars'"; |
74
|
|
|
|
75
|
|
|
$this->assertEquals( |
76
|
|
|
$expected, |
77
|
|
|
(new \Robo\Task\Gulp\Run('anotherWith weired!("\') Chars','gulp'))->getCommand() |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
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.