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

testNonExistentNthParameterThrowsException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php namespace Chekote\NounStore\Store;
2
3
use InvalidArgumentException;
4
use OutOfBoundsException;
5
6
/**
7
 * @covers Store::assertHas()
8
 */
9
class AssertHasTest extends StoreTest
10
{
11
    public function testMismatchedNthInKeyAndParamAreRejected()
12
    {
13
        $this->expectException(InvalidArgumentException::class);
14
15
        /* @noinspection PhpUnhandledExceptionInspection */
16
        $this->store->assertHas('1st Thing', 1);
17
    }
18
19
    public function testKeyWithExistingNthReturnsValue()
20
    {
21
        /* @noinspection PhpUnhandledExceptionInspection */
22
        $this->assertEquals(self::FIRST_VALUE, $this->store->assertHas('1st ' . self::KEY));
23
    }
24
25
    public function testKeyWithNonExistingNthThrowsException()
26
    {
27
        $this->expectException(OutOfBoundsException::class);
28
        $this->expectExceptionMessage("Entry '3rd " . self::KEY . "' was not found in the store.");
29
30
        /* @noinspection PhpUnhandledExceptionInspection */
31
        $this->store->assertHas('3rd ' . self::KEY);
32
    }
33
34
    public function testExistingNthParameterReturnsValue()
35
    {
36
        /* @noinspection PhpUnhandledExceptionInspection */
37
        $this->assertEquals(self::FIRST_VALUE, $this->store->assertHas(self::KEY, 0));
38
    }
39
40
    public function testNonExistentNthParameterThrowsException()
41
    {
42
        $this->expectException(OutOfBoundsException::class);
43
        $this->expectExceptionMessage("Entry '3rd " . self::KEY . "' was not found in the store.");
44
45
        /* @noinspection PhpUnhandledExceptionInspection */
46
        $this->store->assertHas(self::KEY, 2);
47
    }
48
}
49