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

CalculatorEqualPaymentsTest::generator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
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