|
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
|
|
|
|