Passed
Push — master ( 639b92...a2ec98 )
by Donald
13:52
created

testGetThrowsInvalidArgumentExceptionWithMismatchedNthInKeyAndParam()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Chekote\NounStore\Store;
2
3
use InvalidArgumentException;
4
5
/**
6
 * @covers Store::get()
7
 */
8
class GetTest extends StoreTest
9
{
10
    /**
11
     * Tests that InvalidArgumentException is thrown if Store::get is called with the nth parameter
12
     * and the key also contains an nth value, but they do not match.
13
     */
14
    public function testGetThrowsInvalidArgumentExceptionWithMismatchedNthInKeyAndParam()
15
    {
16
        $this->expectException(InvalidArgumentException::class);
17
18
        $this->store->get('1st Thing', 1);
19
    }
20
21
    /**
22
     * Tests that Store::get returns the item at the end of the stack.
23
     */
24
    public function testGetReturnsItemAtEndOfStack()
25
    {
26
        $this->assertEquals(self::SECOND_VALUE, $this->store->get(self::KEY));
27
    }
28
29
    /**
30
     * Tests that Store::get returns the nth item at of the stack when the $key contains nth.
31
     */
32
    public function testGetWithNthKeyReturnsNthItem()
33
    {
34
        $this->assertEquals(self::FIRST_VALUE, $this->store->get('1st ' . self::KEY));
35
    }
36
37
    /**
38
     * Tests that Store::get returns the nth item at of the stack when $nth parameter is provided.
39
     */
40
    public function testGetWithNthParameterReturnsNthItem()
41
    {
42
        $this->assertEquals(self::FIRST_VALUE, $this->store->get(self::KEY, 0));
43
    }
44
45
    /**
46
     * Tests that Store::get returns null when the specified $key does not exist.
47
     */
48
    public function testGetReturnsNullWhenKeyDoesNotExist()
49
    {
50
        $this->assertEquals(null, $this->store->get('Thing'));
51
    }
52
53
    /**
54
     * Tests that Store::get returns null when the specified nth $key does not exist.
55
     */
56
    public function testGetReturnsNullWhenNthKeyDoesNotExist()
57
    {
58
        $this->assertEquals(null, $this->store->get('3rd ' . self::KEY));
59
    }
60
61
    /**
62
     * Tests that Store::get returns null when the specified $nth param does not exist.
63
     */
64
    public function testGetReturnsNullWhenNthDoesNotExist()
65
    {
66
        $this->assertEquals(null, $this->store->get(self::KEY, 2));
67
    }
68
}
69