Test Setup Failed
Push — master ( 562b48...254002 )
by Gabriel
04:15 queued 14s
created

HasStoresTraitTest::test_store_default_no_name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Nip\Cache\Tests\CacheManager;
4
5
use Mockery\Mock;
6
use Nip\Cache\CacheManager;
7
use Nip\Cache\Stores\Repository;
8
use Nip\Cache\Tests\AbstractTest;
9
10
/**
11
 * Class HasStoresTraitTest
12
 * @package Nip\Cache\Tests\CacheManager
13
 */
14
class HasStoresTraitTest extends AbstractTest
15
{
16
    public function test_store_default_no_name()
17
    {
18
        /** @var Mock|CacheManager $manager */
19
        $manager = \Mockery::mock(CacheManager::class)->shouldAllowMockingProtectedMethods()->makePartial();
20
        $manager->shouldReceive('getDefaultStore')->andReturn('default_value');
0 ignored issues
show
Bug introduced by
The method shouldReceive does only exist in Mockery\Mock, but not in Nip\Cache\CacheManager.

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...
21
        $manager->shouldReceive('getStore')->with('default_value')->andReturn(true);
22
23
        self::assertTrue($manager->store(null));
0 ignored issues
show
Bug introduced by
The method store does only exist in Nip\Cache\CacheManager, but not in Mockery\Mock.

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...
24
        self::assertTrue($manager->store(0));
25
        self::assertTrue($manager->store(''));
26
    }
27
28
    public function test_store_file_no_config()
29
    {
30
        /** @var Mock|CacheManager $manager */
31
        $manager = \Mockery::mock(CacheManager::class)->shouldAllowMockingProtectedMethods()->makePartial();
32
        $manager->shouldReceive('getConfig')->andReturnUsing(function ($name, $default) {
0 ignored issues
show
Bug introduced by
The method shouldReceive does only exist in Mockery\Mock, but not in Nip\Cache\CacheManager.

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...
33
            return $default;
34
        });
35
36
        $store = $manager->store();
0 ignored issues
show
Bug introduced by
The method store does only exist in Nip\Cache\CacheManager, but not in Mockery\Mock.

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...
37
        self::assertInstanceOf(Repository::class, $store);
38
    }
39
}
40