Passed
Pull Request — 2.0 (#36)
by Donald
02:59 queued 01:27
created

IsPossessiveTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 1
nc 1
nop 0
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
    public function setUp()
11
    {
12
        parent::setUp();
13
14
        /* @noinspection PhpUndefinedMethodInspection */
15
        Phake::when($this->key)->isPossessive(Phake::anyParameters())->thenCallParent();
0 ignored issues
show
Bug introduced by
It seems like $this->key can also be of type Chekote\NounStore\Key; however, parameter $mock of Phake::when() does only seem to accept Phake_IMock, maybe add an additional type check? ( Ignorable by Annotation )

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

15
        Phake::when(/** @scrutinizer ignore-type */ $this->key)->isPossessive(Phake::anyParameters())->thenCallParent();
Loading history...
16
    }
17
18
    /**
19
     * @dataProvider possessiveNouns
20
     */
21
    public function testReturnsTrueForPossessiveNoun($noun)
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 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...
Bug introduced by
It seems like $this->key can also be of type Chekote\NounStore\Key; however, parameter $mock of Chekote\Phake\Phake::makeVisible() does only seem to accept Phake_IMock, maybe add an additional type check? ( Ignorable by Annotation )

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

25
        Phake::makeVisible(/** @scrutinizer ignore-type */ $this->key)->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 string[]
34
     */
35
    public function possessiveNouns()
36
    {
37
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(array('Cust...h Customer's 4th Car')) returns the type array<integer,array<integer,string>> which is incompatible with the documented return type string[].
Loading history...
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)
49
    {
50
        /* @noinspection PhpUndefinedMethodInspection */
51
        $this->assertFalse(
52
        Phake::makeVisible($this->key)->isPossessive($noun),
0 ignored issues
show
Bug introduced by
It seems like $this->key can also be of type Chekote\NounStore\Key; however, parameter $mock of Chekote\Phake\Phake::makeVisible() does only seem to accept Phake_IMock, maybe add an additional type check? ( Ignorable by Annotation )

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

52
        Phake::makeVisible(/** @scrutinizer ignore-type */ $this->key)->isPossessive($noun),
Loading history...
53
        "'$noun' should not be considered a possessive noun"
54
    );
55
    }
56
57
    /**
58
     * Data provider of non possessive nouns.
59
     *
60
     * @return string[]
61
     */
62
    public function nonPossessiveNouns()
63
    {
64
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(array('Item'), array('1st Item')) returns the type array<integer,array<integer,string>> which is incompatible with the documented return type string[].
Loading history...
65
            ['Item'],
66
            ['1st Item'],
67
        ];
68
    }
69
}
70