Completed
Push — develop ( f3a4fe...df0b60 )
by Tom
03:55
created

DumpCommandTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 7 1
1
<?php
2
3
namespace N98\Magento\Command\Media;
4
5
use N98\Magento\Command\TestCase;
6
7
class DumpCommandTest extends TestCase
8
{
9
    public function testExecute()
10
    {
11
        $this->assertDisplayContains(
12
            'media:dump',
13
            sprintf('media/theme/preview', $this->getApplication()->getVersion())
0 ignored issues
show
Bug introduced by
The method getVersion 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
        );
15
    }
16
}
17