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
|
|
|
|
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: