FactorialTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 57
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A provideFactorialsWithResults() 0 12 1
A provideNegativeNumbers() 0 15 1
A factorialize_numberToFactorialize_factorizationResult() 0 8 1
A factorialize_negativeNumber_wrongArgumentException() 0 7 1
1
<?php
2
3
namespace Tests;
4
5
use Vehsamrak\Factorial\Factorial;
6
7
class FactorialTest extends \PHPUnit_Framework_TestCase
8
{
9
10
    public function provideFactorialsWithResults(): array
11
    {
12
        return [
13
            [0, 1],
14
            [1, 1],
15
            [2, 2],
16
            [3, 6],
17
            [4, 24],
18
            [5, 120],
19
            [6, 720],
20
        ];
21
    }
22
23
    public function provideNegativeNumbers(): array
24
    {
25
        return [
26
            [-1],
27
            [-2],
28
            [-3],
29
            [-4],
30
            [-5],
31
            [-6],
32
            [-7],
33
            [-8],
34
            [-9],
35
            [-10],
36
        ];
37
    }
38
39
    /**
40
     * @test
41
     * @dataProvider provideFactorialsWithResults
42
     */
43
    public function factorialize_numberToFactorialize_factorizationResult(int $numberToFactorialize, int $result): void
44
    {
45
        $factorial = new Factorial();
46
47
        $factorialResult = $factorial->factorialize($numberToFactorialize);
48
49
        $this->assertEquals($result, $factorialResult);
50
    }
51
52
    /**
53
     * @test
54
     * @dataProvider provideNegativeNumbers
55
     */
56
    public function factorialize_negativeNumber_wrongArgumentException(int $numberToFactorialize): void
57
    {
58
        $factorial = new Factorial();
59
60
        $this->expectException(\InvalidArgumentException::class);
61
        $factorial->factorialize($numberToFactorialize);
62
    }
63
}
64