IsPossessiveTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 59
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A testReturnsFalseForNonPossessiveNoun() 0 6 1
A possessiveNouns() 0 7 1
A nonPossessiveNouns() 0 5 1
A testReturnsTrueForPossessiveNoun() 0 6 1
1
<?php namespace Unit\Chekote\NounStore\Key;
2
3
use Unit\Chekote\Phake\Phake;
4
5
/**
6
 * @covers \Chekote\NounStore\Key::isPossessive()
7
 */
8
class IsPossessiveTest extends KeyTestCase
9
{
10
    public function setUp(): void
11
    {
12
        parent::setUp();
13
14
        /* @noinspection PhpUndefinedMethodInspection */
15
        Phake::when($this->key)->isPossessive(Phake::anyParameters())->thenCallParent();
16
    }
17
18
    /**
19
     * @dataProvider possessiveNouns
20
     */
21
    public function testReturnsTrueForPossessiveNoun($noun): void
22
    {
23
        /* @noinspection PhpUndefinedMethodInspection */
24
        $this->assertTrue(
25
            Phake::makeVisible($this->key)->isPossessive($noun),
0 ignored issues
show
Bug introduced by
The method isPossessive() does not exist on Unit\Chekote\Phake\Proxies\VisibilityProxy. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            Phake::makeVisible($this->key)->/** @scrutinizer ignore-call */ isPossessive($noun),
Loading history...
26
            "'$noun' should be considered a possessive noun"
27
        );
28
    }
29
30
    /**
31
     * Data provider of possessive nouns.
32
     *
33
     * @return array[]
34
     */
35
    public static function possessiveNouns(): array
36
    {
37
        return [
38
            ["Customer's Car"],
39
            ["8th Customer's Car"],
40
            ["Customer's 2nd Car"],
41
            ["7th Customer's 4th Car"],
42
        ];
43
    }
44
45
    /**
46
     * @dataProvider nonPossessiveNouns
47
     */
48
    public function testReturnsFalseForNonPossessiveNoun($noun): void
49
    {
50
        /* @noinspection PhpUndefinedMethodInspection */
51
        $this->assertFalse(
52
            Phake::makeVisible($this->key)->isPossessive($noun),
53
            "'$noun' should not be considered a possessive noun"
54
        );
55
    }
56
57
    /**
58
     * Data provider of non possessive nouns.
59
     *
60
     * @return array[]
61
     */
62
    public static function nonPossessiveNouns(): array
63
    {
64
        return [
65
            ['Item'],
66
            ['1st Item'],
67
        ];
68
    }
69
}
70