Completed
Push — master ( 9f49d7...5b6cd1 )
by Tobias
02:51
created

CalculatorEqualPaymentsTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testWithEqualPayments() 0 6 1
A generator() 0 7 1
1
<?php
2
3
namespace Nyholm\EffectiveInterest\Test;
4
5
use Nyholm\EffectiveInterest\Calculator;
6
use PHPUnit\Framework\TestCase;
7
8
class CalculatorEqualPaymentsTest extends TestCase
9
{
10
    /**
11
     * @dataProvider generator
12
     */
13
    public function testWithEqualPayments(float $correctValue, int $principal, int $payment, int $numberOfMonths, float $guess)
14
    {
15
        $calculator = new Calculator();
16
        $interest = $calculator->withEqualPayments($principal, $payment, $numberOfMonths, $guess);
17
        $this->assertEquals($correctValue, $interest, 'Failed to calculate effective interest with specified payments.', 0.0001);
18
    }
19
20
    public function generator()
21
    {
22
        return [
23
            [0.1128, 11200, 291, 48, 0.02],
24
            [0.0712, 100000, 2400, 48, 0.03],
25
        ];
26
    }
27
28
}
29