OblistCollectionTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateOblist() 0 7 1
A testGetOblistExists() 0 6 1
A testGetOblistDoesNotExist() 0 4 1
A oblistCollectionProvider() 0 6 1
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