OblistTest::testCreateAtomDoesNotExist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
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