GulpTest::testGulpRun()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
use AspectMock\Test as test;
0 ignored issues
show
Bug introduced by
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
        $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()
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...
57
    {
58
        $gulp = test::double('Robo\Task\Gulp\Run', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]);
0 ignored issues
show
Deprecated Code introduced by
The class Robo\Config has been deprecated with message: Use \Robo\Config\Config

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

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

Loading history...
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