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

testHasThrowsInvalidArgumentExceptionWithMismatchedNthInKeyAndParam()   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::has()
7
 */
8
class HasTest extends StoreTest
9
{
10
    /**
11
     * Tests that InvalidArgumentException is thrown if Store::has is called with the nth parameter
12
     * and the key also contains an nth value, but they do not match.
13
     */
14
    public function testHasThrowsInvalidArgumentExceptionWithMismatchedNthInKeyAndParam()
15
    {
16
        $this->expectException(InvalidArgumentException::class);
17
18
        $this->store->has('1st Thing', 1);
19
    }
20
21
    /**
22
     * Tests that store::has returns true if nth value in key is found in store.
23
     */
24
    public function testHasWithExistingNthKeyReturnsTrue()
25
    {
26
        $this->assertTrue($this->store->has('1st ' . self::KEY));
27
    }
28
29
    /**
30
     * Tests that store::has returns false if nth value in key is not found in store.
31
     */
32
    public function testHasWithMissingNthKeyReturnsFalse()
33
    {
34
        $this->assertFalse($this->store->has('3rd ' . self::KEY));
35
    }
36
37
    /**
38
     * Tests that store::has returns true if nth param value is found in store.
39
     */
40
    public function testHasWithExistingNthParameterReturnsTrue()
41
    {
42
        $this->assertTrue($this->store->has(self::KEY, 0));
43
    }
44
45
    /**
46
     * Tests that store::has returns false if nth param value is not found in store.
47
     */
48
    public function testHasWithMissingNthParameterReturnsFalse()
49
    {
50
        $this->assertFalse($this->store->has(self::KEY, 2));
51
    }
52
}
53