Passed
Push — possessive_nouns ( 401fcf )
by Donald
02:30
created

IsPossessiveTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A possessiveNouns() 0 6 1
A nonPossessiveNouns() 0 4 1
A testReturnsTrueForPossessiveNoun() 0 5 1
A testReturnsFalseForNonPossessiveNoun() 0 5 1
A setUp() 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
  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
    /* @noinspection PhpUndefinedMethodInspection */
23
    $this->assertTrue(
24
        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

24
        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

24
        Phake::makeVisible(/** @scrutinizer ignore-type */ $this->key)->isPossessive($noun),
Loading history...
25
        "'$noun' should be considered a possessive noun"
26
    );
27
  }
28
29
  /**
30
   * Data provider of possessive nouns
31
   *
32
   * @return string[]
33
   */
34
  public function possessiveNouns() {
35
    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...
36
        ["Customer's Car"],
37
        ["8th Customer's Car"],
38
        ["Customer's 2nd Car"],
39
        ["7th Customer's 4th Car"],
40
    ];
41
  }
42
43
  /**
44
   * @dataProvider nonPossessiveNouns
45
   */
46
  public function testReturnsFalseForNonPossessiveNoun($noun) {
47
    /* @noinspection PhpUndefinedMethodInspection */
48
    $this->assertFalse(
49
        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

49
        Phake::makeVisible(/** @scrutinizer ignore-type */ $this->key)->isPossessive($noun),
Loading history...
50
        "'$noun' should not be considered a possessive noun"
51
    );
52
  }
53
54
  /**
55
   * Data provider of non possessive nouns
56
   *
57
   * @return string[]
58
   */
59
  public function nonPossessiveNouns() {
60
    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...
61
        ['Item'],
62
        ['1st Item'],
63
    ];
64
  }
65
}
66