Passed
Branch scrutinizer_complaint (bc9618)
by Donald
02:48
created

GetOrdinalTest::successScenariosDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 7
nc 1
nop 0
1
<?php namespace Chekote\NounStore\Key;
2
3
use Chekote\Phake\Phake;
4
use InvalidArgumentException;
5
6
/**
7
 * @covers \Chekote\NounStore\Key::getOrdinal()
8
 */
9
class GetOrdinalTest extends KeyTest
10
{
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        /* @noinspection PhpUndefinedMethodInspection */
16
        Phake::when($this->key)->getOrdinal(Phake::anyParameters())->thenCallParent();
17
    }
18
19
    public function successScenariosDataProvider()
20
    {
21
        return [
22
            [0,   'th'], [1,   'st'], [2,   'nd'], [3,   'rd'],
23
            [4,   'th'], [5,   'th'], [6,   'th'], [7,   'th'],
24
            [8,   'th'], [9,   'th'], [10,  'th'], [11,  'th'],
25
            [12,  'th'], [13,  'th'], [14,  'th'], [21,  'st'],
26
            [22,  'nd'], [23,  'rd'], [24,  'th'], [101, 'st'],
27
            [102, 'nd'], [103, 'rd'], [104, 'th'],
28
        ];
29
    }
30
31
    public function failureScenariosDataProvider()
32
    {
33
        return [
34
        //   nth  exception class                  exception message
35
            [-1,  InvalidArgumentException::class, '$nth must be a positive number'],
36
        ];
37
    }
38
39
    /**
40
     * Executes a success scenario against the method.
41
     *
42
     * @dataProvider successScenariosDataProvider
43
     * @param int    $nth      the nth to pass to the method.
44
     * @param string $expected the ordinal expected from the method.
45
     */
46
    public function testSuccessScenario($nth, $expected)
47
    {
48
        $this->assertEquals($expected, $this->key->getOrdinal($nth));
49
    }
50
51
    /**
52
     * Executes a failure scenario against the method.
53
     *
54
     * @dataProvider failureScenariosDataProvider
55
     * @param int    $nth              the nth to pass to the method.
56
     * @param string $exceptionClass   the expected class of the exception.
57
     * @param string $exceptionMessage the expected message of the exception.
58
     */
59
    public function testFailureScenario($nth, $exceptionClass, $exceptionMessage)
60
    {
61
        $this->expectException($exceptionClass);
62
        $this->expectExceptionMessage($exceptionMessage);
63
64
        $this->key->getOrdinal($nth);
65
    }
66
}
67