SetTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetOnceStoresValue() 0 12 1
A testSetTwiceForSameKeyStoresMultipleValues() 0 15 1
A setUp() 0 6 1
1
<?php namespace Unit\Chekote\NounStore\Store;
2
3
use Unit\Chekote\Phake\Phake;
4
5
class SetTest extends StoreTestCase
6
{
7
    public function setUp(): void
8
    {
9
        parent::setUp();
10
11
        /* @noinspection PhpUndefinedMethodInspection */
12
        Phake::when($this->store)->set(Phake::anyParameters())->thenCallParent();
13
    }
14
15
    /**
16
     * Tests that calling store::set once stores the value correctly.
17
     */
18
    public function testSetOnceStoresValue(): void
19
    {
20
        $key = 'My Key';
21
        $value = 'My Value';
22
23
        $this->store->set($key, $value);
0 ignored issues
show
Bug introduced by
The method set() 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

23
        $this->store->/** @scrutinizer ignore-call */ 
24
                      set($key, $value);

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...
Bug introduced by
The method set() does not exist on Unit\Chekote\NounStore\Store\StorePhake. ( Ignorable by Annotation )

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

23
        $this->store->/** @scrutinizer ignore-call */ 
24
                      set($key, $value);

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...
24
25
        $store = Phake::makeVisible($this->store);
26
        /* @noinspection PhpUndefinedFieldInspection */
27
        {
28
            $this->assertCount(1, $store->nouns[$key]);
0 ignored issues
show
Bug Best Practice introduced by
The property nouns does not exist on Unit\Chekote\Phake\Proxies\VisibilityProxy. Since you implemented __get, consider adding a @property annotation.
Loading history...
29
            $this->assertEquals($value, $store->nouns[$key][0]);
30
        }
31
    }
32
33
    /**
34
     * Tests that calling store::set twice for the same key stores both values correctly.
35
     */
36
    public function testSetTwiceForSameKeyStoresMultipleValues(): void
37
    {
38
        $key = 'My Key';
39
        $value1 = 'My Value';
40
        $value2 = 'My Second Value';
41
42
        $this->store->set($key, $value1);
43
        $this->store->set($key, $value2);
44
45
        $store = Phake::makeVisible($this->store);
46
        /* @noinspection PhpUndefinedFieldInspection */
47
        {
48
            $this->assertCount(2, $store->nouns[$key]);
0 ignored issues
show
Bug Best Practice introduced by
The property nouns does not exist on Unit\Chekote\Phake\Proxies\VisibilityProxy. Since you implemented __get, consider adding a @property annotation.
Loading history...
49
            $this->assertEquals($value1, $store->nouns[$key][0]);
50
            $this->assertEquals($value2, $store->nouns[$key][1]);
51
        }
52
    }
53
}
54