Completed
Push — master ( d3a073...5737c8 )
by Greg
02:21
created

tests/unit/Task/GulpTest.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
use AspectMock\Test as test;
0 ignored issues
show
This use statement conflicts with another class in this namespace, test.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/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 before OtherDir/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:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
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
        verify(
26
            (new \Robo\Task\Gulp\Run('default','gulp'))->getCommand()
27
        )->equals($this->adjustQuotes("gulp 'default'"));
28
29
        verify(
30
            (new \Robo\Task\Gulp\Run('another','gulp'))->getCommand()
31
        )->equals($this->adjustQuotes("gulp 'another'"));
32
33
        verify(
34
            (new \Robo\Task\Gulp\Run('default','gulp'))->silent()->getCommand()
35
        )->equals($this->adjustQuotes("gulp 'default' --silent"));
36
37
        verify(
38
            (new \Robo\Task\Gulp\Run('default','gulp'))->noColor()->getCommand()
39
        )->equals($this->adjustQuotes("gulp 'default' --no-color"));
40
41
        verify(
42
            (new \Robo\Task\Gulp\Run('default','gulp'))->color()->getCommand()
43
        )->equals($this->adjustQuotes("gulp 'default' --color"));
44
45
        verify(
46
            (new \Robo\Task\Gulp\Run('default','gulp'))->simple()->getCommand()
47
        )->equals($this->adjustQuotes("gulp 'default' --tasks-simple"));
48
    }
49
50 View Code Duplication
    public function testGulpRun()
51
    {
52
        $gulp = test::double('Robo\Task\Gulp\Run', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]);
53
54
        $task = (new \Robo\Task\Gulp\Run('default','gulp'))->simple();
55
        verify($task->getCommand())->equals($this->adjustQuotes("gulp 'default' --tasks-simple"));
56
        $task->run();
57
        $gulp->verifyInvoked('executeCommand', [$this->adjustQuotes("gulp 'default' --tasks-simple")]);
58
    }
59
60
    public function testGulpUnusualChars()
61
    {
62
        $isWindows = defined('PHP_WINDOWS_VERSION_MAJOR');
63
64
        if ($isWindows) {
65
66
            verify(
67
                (new \Robo\Task\Gulp\Run('anotherWith weired!("\') Chars','gulp'))->getCommand()
68
            )->equals('gulp "anotherWith weired!(\"\') Chars"');
69
70
        } else {
71
72
            verify(
73
                (new \Robo\Task\Gulp\Run('anotherWith weired!("\') Chars','gulp'))->getCommand()
74
            )->equals("gulp 'anotherWith weired!(\"'\\'') Chars'");
75
76
        }
77
    }
78
}
79