OblistTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 0 Features 1
Metric Value
dl 0
loc 67
rs 10
c 4
b 0
f 1
wmc 6
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateAtomDoesNotExist() 0 6 1
A testCreateAtomExists() 0 7 1
A testGetObjectExists() 0 6 1
A testGetObjectDoesNotExist() 0 4 1
A oblistPropertyProvider() 0 10 2
1
<?php
2
3
/**
4
 * @file
5
 * Tests for Itafroma\Zork\State\Oblist
6
 */
7
8
namespace Itafroma\Zork\Tests;
9
10
use Itafroma\Zork\State\Oblist;
11
12
class OblistTest extends ZorkTest
13
{
14
    /**
15
     * Tests Itafroma\Zork|State\Oblist::create() when the atom does not exist.
16
     *
17
     * @covers Itafroma\Zork\State\Oblist::create
18
     * @dataProvider oblistPropertyProvider
19
     */
20
    public function testCreateAtomDoesNotExist($oblist, $property_name)
21
    {
22
        $return = $oblist->create($property_name);
23
24
        $this->assertNull($return);
25
    }
26
27
    /**
28
     * Tests Itafroma\Zork|State\Oblist::create() when the atom already exists.
29
     *
30
     * @covers Itafroma\Zork\State\Oblist::create
31
     * @dataProvider oblistPropertyProvider
32
     */
33
    public function testCreateAtomExists($oblist, $property_name, $property_value)
34
    {
35
        $oblist->set($property_name, $property_value);
36
        $return = $oblist->create($property_name);
37
38
        $this->assertEquals($property_value, $return);
39
    }
40
41
    /**
42
     * Tests Itafroma\Zork\State\Oblist::get() when the requested object exists.
43
     *
44
     * @covers Itafroma\Zork\State\Oblist::get
45
     * @dataProvider oblistPropertyProvider
46
     */
47
    public function testGetObjectExists($oblist, $property_name, $property_value)
48
    {
49
        $this->setPrivateProperty($oblist, 'atoms', [$property_name => $property_value]);
50
51
        $this->assertEquals($property_value, $oblist->get($property_name));
52
    }
53
54
    /**
55
     * Tests Itafroma\Zork\State\Oblist::get() when the requested object does not exist.
56
     *
57
     * @covers Itafroma\Zork\State\Oblist::get
58
     * @dataProvider oblistPropertyProvider
59
     */
60
    public function testGetObjectDoesNotExist($oblist, $property_name)
61
    {
62
        $this->assertFalse($oblist->get($property_name));
63
    }
64
65
    /**
66
     * Provides an oblist with a test property and value.
67
     */
68
    public function oblistPropertyProvider()
69
    {
70
        $properties = $this->propertyProvider();
71
72
        foreach ($properties as &$property) {
73
            array_unshift($property, new Oblist());
74
        }
75
76
        return $properties;
77
    }
78
}
79