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

DumpCommandTest::testExecute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
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