Completed
Push — master ( 5017d8...561e2a )
by Christian
07:36 queued 03:33
created

AclCommandTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A itShouldLoadGlobalConfig() 0 14 1
1
<?php
2
3
namespace N98\Magento\Command\Config\Data;
4
5
use N98\Magento\Command\TestCase;
6
use Symfony\Component\Console\Tester\CommandTester;
7
8
class AclCommandTest extends TestCase
9
{
10
    /**
11
     * @test
12
     * @outputBuffering off
13
     */
14
    public function itShouldLoadGlobalConfig()
15
    {
16
        $command = $this->getApplication()->find('config:data:acl');
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...
17
18
        $commandTester = new CommandTester($command);
19
        $commandTester->execute(
20
            array(
21
                'command' => 'config:data:acl',
22
            )
23
        );
24
25
        $this->assertContains('All Stores', $commandTester->getDisplay());
26
        $this->assertContains('Magento_Reports::salesroot_sales', $commandTester->getDisplay());
27
    }
28
}
29