Passed
Pull Request — master (#1312)
by Michael
08:02 queued 01:46
created

ArrayStorageTest::testDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 11
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xmf\Test\Key;
6
7
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
10
use Xmf\Key\ArrayStorage;
11
12
class ArrayStorageTest extends TestCase
13
{
14
    /**
15
     * @var ArrayStorage
16
     */
17
    protected $object;
18
19
    /**
20
     * Sets up the fixture, for example, opens a network connection.
21
     * This method is called before a test is executed.
22
     */
23
    protected function setUp(): void
24
    {
25
        $this->object = new ArrayStorage();
26
    }
27
28
    /**
29
     * Tears down the fixture, for example, closes a network connection.
30
     * This method is called after a test is executed.
31
     */
32
    protected function tearDown(): void
33
    {
34
    }
35
36
    public function testSave()
37
    {
38
        $name = 'name';
39
        $data = 'data';
40
        $this->object->save($name, $data);
41
        $this->assertEquals($data, $this->object[$name]);
42
    }
43
44
    public function testFetch()
45
    {
46
        $name = 'name';
47
        $data = 'data';
48
        $this->assertFalse($this->object->fetch($name));
49
        $this->object->save($name, $data);
50
        $this->assertEquals($this->object->fetch($name), $data);
51
    }
52
53
    public function testExists()
54
    {
55
        $name = 'name';
56
        $data = 'data';
57
        $this->assertFalse($this->object->exists($name));
58
        $this->object->save($name, $data);
59
        $this->assertTrue($this->object->exists($name));
60
    }
61
62
    public function testDelete()
63
    {
64
        $name = 'name';
65
        $data = 'data';
66
        $this->object->save($name, $data);
67
        $this->assertTrue($this->object->exists($name));
68
        $actual = $this->object->delete($name);
69
        $this->assertTrue($actual);
70
        $actual = $this->object->delete($name);
71
        $this->assertFalse($actual);
72
        $this->assertFalse($this->object->exists($name));
73
    }
74
}
75