1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file |
5
|
|
|
* Tests for oblist collections. |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace Itafroma\Zork\Tests; |
9
|
|
|
|
10
|
|
|
use Itafroma\Zork\State\Oblist; |
11
|
|
|
use Itafroma\Zork\State\OblistCollection; |
12
|
|
|
|
13
|
|
|
class OblistCollectionTest extends ZorkTest |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Tests Itafroma\Zork\OblistCollection::create(). |
17
|
|
|
* |
18
|
|
|
* @covers Itafroma\Zork\State\OblistCollection::create |
19
|
|
|
* @dataProvider oblistCollectionProvider |
20
|
|
|
*/ |
21
|
|
|
public function testCreateOblist($oblist_collection, $name) |
22
|
|
|
{ |
23
|
|
|
$return = $oblist_collection->create($name); |
24
|
|
|
|
25
|
|
|
$this->assertInstanceOf(Oblist::class, $return); |
26
|
|
|
$this->assertEquals($return, $this->getPrivateProperty($oblist_collection, 'atoms')[$name]); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Tests Itafroma\Zork\State\OblistCollection::get() when the oblist exists. |
31
|
|
|
* |
32
|
|
|
* @covers Itafroma\Zork\State\OblistCollection::get |
33
|
|
|
* @dataProvider oblistCollectionProvider |
34
|
|
|
*/ |
35
|
|
|
public function testGetOblistExists($oblist_collection, $name, $oblist) |
36
|
|
|
{ |
37
|
|
|
$this->setPrivateProperty($oblist_collection, 'atoms', [$name => $oblist]); |
38
|
|
|
|
39
|
|
|
$this->assertEquals($oblist, $oblist_collection->get($name)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Tests Itafroma\Zork\State\OblistCollection::get() when the oblist does not exist. |
44
|
|
|
* |
45
|
|
|
* @covers Itafroma\Zork\State\OblistCollection::get |
46
|
|
|
* @dataProvider oblistCollectionProvider |
47
|
|
|
*/ |
48
|
|
|
public function testGetOblistDoesNotExist($oblist_collection, $name) |
49
|
|
|
{ |
50
|
|
|
$this->assertEquals(null, $oblist_collection->get($name)); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Provides data for testing oblist collections. |
55
|
|
|
*/ |
56
|
|
|
public function oblistCollectionProvider() |
57
|
|
|
{ |
58
|
|
|
return [ |
59
|
|
|
[new OblistCollection(), 'ZorkTest-name', new Oblist()], |
60
|
|
|
]; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|