StoreTestCase   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 22
c 1
b 0
f 0
dl 0
loc 56
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A tearDown() 0 6 1
A initialize() 0 13 1
A setUp() 0 7 1
1
<?php namespace Unit\Chekote\NounStore\Store;
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 11 and the first side effect is on line 70.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
use Chekote\NounStore\Key;
4
use Chekote\NounStore\Store;
5
use Phake\IMock;
6
use stdClass;
7
use Unit\Chekote\NounStore\Assert\KeyPhake;
8
use Unit\Chekote\NounStore\TestCase;
9
use Unit\Chekote\Phake\Phake;
10
11
abstract class StoreTestCase extends TestCase
12
{
13
    protected IMock|KeyPhake $key;
14
15
    protected IMock|StorePhake $store;
16
17
    /** the first value stored under self::KEY */
18
    protected static stdClass $firstValue;
19
20
    /** the second value stored under self::KEY */
21
    protected static stdClass $secondValue;
22
23
    /** the most recent value stored under self::KEY */
24
    public static stdClass $mostRecentValue;
25
26
    const KEY = 'Car';
27
28
    /**
29
     * Sets up the classes initial static state.
30
     */
31
    public static function initialize(): void
32
    {
33
        $car1 = new stdClass();
34
        $car1->color = 'Red';
35
        $car1->option = ['GPS', 'Heated Seats'];
36
37
        $car2 = new stdClass();
38
        $car2->color = 'Blue';
39
        $car2->option = ['Cruise Control', 'Air Conditioning'];
40
41
        self::$firstValue = $car1;
42
        self::$secondValue = $car2;
43
        self::$mostRecentValue = $car2;
44
    }
45
46
    /**
47
     * Sets up the environment before each test.
48
     */
49
    public function setUp(): void
50
    {
51
        $this->key = Phake::strictMock(Key::class);
52
        $this->store = Phake::strictMockWithConstructor(Store::class, $this->key);
53
54
        /* @noinspection PhpUndefinedFieldInspection */
55
        Phake::makeVisible($this->store)->nouns = [self::KEY => [self::$firstValue, self::$secondValue]];
0 ignored issues
show
Bug Best Practice introduced by
The property nouns does not exist on Unit\Chekote\Phake\Proxies\VisibilityProxy. Since you implemented __set, consider adding a @property annotation.
Loading history...
56
    }
57
58
    /**
59
     * Tears down the environment after each test.
60
     */
61
    public function tearDown(): void
62
    {
63
        unset($this->key);
64
        unset($this->store);
65
66
        Phake::verifyExpectations();
67
    }
68
}
69
70
StoreTestCase::initialize();
71