SymlinksCommandTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 31
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testExecute() 0 28 1
1
<?php
2
3
namespace N98\Magento\Command\Developer;
4
5
use Symfony\Component\Console\Tester\CommandTester;
6
use N98\Magento\Command\PHPUnit\TestCase;
7
8
class SymlinksCommandTest extends TestCase
9
{
10
    public function testExecute()
11
    {
12
        $application = $this->getApplication();
13
        $application->add(new SymlinksCommand());
0 ignored issues
show
Bug introduced by
The method add does only exist in N98\Magento\Application, but not in PHPUnit_Framework_MockObject_MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
14
        $application->setAutoExit(false);
0 ignored issues
show
Bug introduced by
The method setAutoExit does only exist in N98\Magento\Application, but not in PHPUnit_Framework_MockObject_MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
15
        $command = $this->getApplication()->find('dev:symlinks');
0 ignored issues
show
Bug introduced by
The method find does only exist in N98\Magento\Application, but not in PHPUnit_Framework_MockObject_MockObject.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
16
17
        $commandTester = new CommandTester($command);
18
        $commandTester->execute(
19
            array(
20
                'command'  => $command->getName(),
21
                '--global' => true,
22
                '--on'     => true,
23
            )
24
        );
25
        $this->assertRegExp('/Symlinks allowed/', $commandTester->getDisplay());
26
27
        $commandTester = new CommandTester($command);
28
        $commandTester->execute(
29
            array(
30
                'command'  => $command->getName(),
31
                '--global' => true,
32
                '--off'    => true,
33
            )
34
        );
35
36
        $this->assertRegExp('/Symlinks denied/', $commandTester->getDisplay());
37
    }
38
}
39