Passed
Branch scrutinizer_new_php_analysis (b739aa)
by Donald
01:58
created

GetAllTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Chekote\NounStore\Store;
2
3
use Chekote\Phake\Phake;
4
use OutOfBoundsException;
5
6
/**
7
 * @covers \Chekote\NounStore\Store::getAll()
8
 */
9
class GetAllTest extends StoreTest
10
{
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        /* @noinspection PhpUndefinedMethodInspection */
16
        Phake::when($this->store)->getAll(Phake::anyParameters())->thenCallParent();
0 ignored issues
show
Bug introduced by
It seems like $this->store can also be of type Chekote\NounStore\Store; however, parameter $mock of Phake::when() does only seem to accept Phake_IMock, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

16
        Phake::when(/** @scrutinizer ignore-type */ $this->store)->getAll(Phake::anyParameters())->thenCallParent();
Loading history...
17
    }
18
19
    /**
20
     * Tests that Store::getAll throws exception when the specified $key does not exist.
21
     */
22
    public function testGetAllThrowsExceptionWhenKeyDoesNotExist()
23
    {
24
        $this->expectException(OutOfBoundsException::class);
25
26
        $this->assertEquals(null, $this->store->getAll('Thing'));
0 ignored issues
show
Bug introduced by
The method getAll() does not exist on Phake_IMock. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
        $this->assertEquals(null, $this->store->/** @scrutinizer ignore-call */ getAll('Thing'));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
    }
28
29
    /**
30
     * Tests that Store::getAll returns all values for specified key.
31
     */
32
    public function testGetAllReturnsAllValuesForSpecifiedKey()
33
    {
34
        $values = $this->store->getAll(self::KEY);
35
36
        $this->assertCount(2, $values);
37
        $this->assertEquals(self::FIRST_VALUE, $values[0]);
38
        $this->assertEquals(self::SECOND_VALUE, $values[1]);
39
    }
40
}
41