Passed
Pull Request — 3.0 (#32)
by Donald
02:33 queued 50s
created

testGetAllThrowsExceptionWhenKeyDoesNotExist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
c 0
b 0
f 0
rs 10
cc 1
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 returns an empty array the specified $key does not exist.
21
     */
22
    public function testGetAllReturnsEmptyArrayWhenKeyDoesNotExist()
23
    {
24
        $this->assertEquals([], $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

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