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

HasTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testHasWithExistingNthParameterReturnsTrue() 0 3 1
A testHasWithMissingNthParameterReturnsFalse() 0 3 1
A testHasWithExistingNthKeyReturnsTrue() 0 3 1
A testHasWithMissingNthKeyReturnsFalse() 0 3 1
A testHasThrowsInvalidArgumentExceptionWithMismatchedNthInKeyAndParam() 0 5 1
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