Failed Conditions
Pull Request — master (#49)
by Donald
03:22 queued 01:40
created

IsPossessiveTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 6 1
A possessiveNouns() 0 7 1
A nonPossessiveNouns() 0 5 1
A testReturnsTrueForPossessiveNoun() 0 9 1
A testReturnsFalseForNonPossessiveNoun() 0 6 1
1
<?php namespace Chekote\NounStore\Key;
2
3
use Chekote\Phake\Phake;
4
5
/**
6
 * @covers \Chekote\NounStore\Key::isPossessive()
7
 */
8
class IsPossessiveTest extends KeyTest
9
{
10
    /** @var string */
11
    const KEY = 'Customer';
12
13
    public function setUp()
14
    {
15
        parent::setUp();
16
17
        /* @noinspection PhpUndefinedMethodInspection */
18
        Phake::when($this->key)->isPossessive(Phake::anyParameters())->thenCallParent();
19
    }
20
21
    /**
22
     * @dataProvider possessiveNouns
23
     */
24
    public function testReturnsTrueForPossessiveNoun($noun)
25
    {
26
        /**
27
         * @noinspection PhpUndefinedMethodInspection
28
         * @scrutinizer  ignore-call
29
         */
30
        $this->assertTrue(
31
            Phake::makeVisible($this->key)->isPossessive($noun),
0 ignored issues
show
Bug introduced by
The method isPossessive() does not exist on 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

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