Completed
Push — master ( b9769b...30fce5 )
by Tobias
24:02
created

CalculatorTest::payments0()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 41
Code Lines 38

Duplication

Lines 41
Ratio 100 %

Importance

Changes 0
Metric Value
dl 41
loc 41
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 38
nc 1
nop 0
1
<?php
2
3
namespace Nyholm\EffectiveInterest;
4
5
use PHPUnit\Framework\TestCase;
6
7
class CalculatorTest extends TestCase
8
{
9
    /**
10
     * @dataProvider generator
11
     */
12
    public function testWithSpecifiedPayments(float $correctValue, int $principal, string $startDate, array $payments, float $guess)
13
    {
14
        $calculator = new Calculator();
15
        $interest = $calculator->withSpecifiedPayments($principal, $startDate, $payments, $guess);
16
        $this->assertEquals($correctValue, $interest, 'Failed to calculate effective interest with specified payments.', 0.00001);
17
    }
18
19
    public function generator()
20
    {
21
        return [
22
            [0.0233, 336000, '2017-01-30', $this->payments0(), 0.02],
23
            [0.0805, 171920, '2017-01-30', $this->payments1(), 0.07],
24
            [0.1045, 52800, '2017-01-30', $this->payments2(), 0.09],
25
            [0.0549, 115000, '2017-01-30', $this->payments3(), 0.04],
26
        ];
27
    }
28
29
    /**
30
     *
31
     * @return array
32
     */
33 View Code Duplication
    private function payments0(): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        return [
36
            '17-02-28' => 4607,
37
            '17-03-31' => 4012,
38
            '17-04-30' => 4012,
39
            '17-05-31' => 4012,
40
            '17-06-30' => 4012,
41
            '17-07-31' => 4012,
42
            '17-08-31' => 4012,
43
            '17-09-30' => 4012,
44
            '17-10-31' => 4012,
45
            '17-11-30' => 4012,
46
            '17-12-31' => 4012,
47
            '18-01-31' => 4012,
48
            '18-02-28' => 4012,
49
            '18-03-31' => 4012,
50
            '18-04-30' => 4012,
51
            '18-05-31' => 4012,
52
            '18-06-30' => 4012,
53
            '18-07-31' => 4012,
54
            '18-08-31' => 4012,
55
            '18-09-30' => 4012,
56
            '18-10-31' => 4012,
57
            '18-11-30' => 4012,
58
            '18-12-31' => 4012,
59
            '19-01-31' => 4012,
60
            '19-02-28' => 4012,
61
            '19-03-31' => 4012,
62
            '19-04-30' => 4012,
63
            '19-05-31' => 4012,
64
            '19-06-30' => 4012,
65
            '19-07-31' => 4012,
66
            '19-08-31' => 4012,
67
            '19-09-30' => 4012,
68
            '19-10-31' => 4012,
69
            '19-11-30' => 4012,
70
            '19-12-31' => 4012,
71
            '20-01-31' => 214012,
72
        ];
73
    }/**
74
     *
75
     * @return array
76
     */
77
    private function payments1(): array
78
    {
79
        return [
80
            '17-02-28' => 4050,
81
            '17-03-31' => 3455,
82
            '17-04-30' => 3455,
83
            '17-05-31' => 3455,
84
            '17-06-30' => 3455,
85
            '17-07-31' => 3455,
86
            '17-08-31' => 3455,
87
            '17-09-30' => 3455,
88
            '17-10-31' => 3455,
89
            '17-11-30' => 3455,
90
            '17-12-31' => 3455,
91
            '18-01-31' => 3455,
92
            '18-02-28' => 3455,
93
            '18-03-31' => 3455,
94
            '18-04-30' => 3455,
95
            '18-05-31' => 3455,
96
            '18-06-30' => 3455,
97
            '18-07-31' => 3455,
98
            '18-08-31' => 3455,
99
            '18-09-30' => 3455,
100
            '18-10-31' => 3455,
101
            '18-11-30' => 3455,
102
            '18-12-31' => 3455,
103
            '19-01-31' => 3455,
104
            '19-02-28' => 3455,
105
            '19-03-31' => 3455,
106
            '19-04-30' => 3455,
107
            '19-05-31' => 3455,
108
            '19-06-30' => 3455,
109
            '19-07-31' => 3455,
110
            '19-08-31' => 3455,
111
            '19-09-30' => 3455,
112
            '19-10-31' => 3455,
113
            '19-11-30' => 3455,
114
            '19-12-31' => 3455,
115
            '20-01-31' => 3455,
116
            '20-02-29' => 3455,
117
            '20-03-31' => 3455,
118
            '20-04-30' => 3455,
119
            '20-05-31' => 3455,
120
            '20-06-30' => 3455,
121
            '20-07-31' => 3455,
122
            '20-08-31' => 3455,
123
            '20-09-30' => 3455,
124
            '20-10-31' => 3455,
125
            '20-11-30' => 3455,
126
            '20-12-31' => 3455,
127
            '21-01-31' => 3455,
128
            '21-02-28' => 3455,
129
            '21-03-31' => 3455,
130
            '21-04-30' => 3455,
131
            '21-05-31' => 3455,
132
            '21-06-30' => 3455,
133
            '21-07-31' => 3455,
134
            '21-08-31' => 3455,
135
            '21-09-30' => 3455,
136
            '21-10-31' => 3455,
137
            '21-11-30' => 3455,
138
            '21-12-31' => 3455,
139
            '22-01-31' => 3455,
140
        ];
141
    }/**
142
     *
143
     * @return array
144
     */
145 View Code Duplication
    private function payments2(): array
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
146
    {
147
        return [
148
            '17-02-28' => 2279,
149
            '17-03-31' => 1684,
150
            '17-04-30' => 1684,
151
            '17-05-31' => 1684,
152
            '17-06-30' => 1684,
153
            '17-07-31' => 1684,
154
            '17-08-31' => 1684,
155
            '17-09-30' => 1684,
156
            '17-10-31' => 1684,
157
            '17-11-30' => 1684,
158
            '17-12-31' => 1684,
159
            '18-01-31' => 1684,
160
            '18-02-28' => 1684,
161
            '18-03-31' => 1684,
162
            '18-04-30' => 1684,
163
            '18-05-31' => 1684,
164
            '18-06-30' => 1684,
165
            '18-07-31' => 1684,
166
            '18-08-31' => 1684,
167
            '18-09-30' => 1684,
168
            '18-10-31' => 1684,
169
            '18-11-30' => 1684,
170
            '18-12-31' => 1684,
171
            '19-01-31' => 1684,
172
            '19-02-28' => 1684,
173
            '19-03-31' => 1684,
174
            '19-04-30' => 1684,
175
            '19-05-31' => 1684,
176
            '19-06-30' => 1684,
177
            '19-07-31' => 1684,
178
            '19-08-31' => 1684,
179
            '19-09-30' => 1684,
180
            '19-10-31' => 1684,
181
            '19-11-30' => 1684,
182
            '19-12-31' => 1684,
183
            '20-01-31' => 1684,
184
        ];
185
    }/**
186
     *
187
     * @return array
188
     */
189
    private function payments3(): array
190
    {
191
        return [
192
            '17-02-28' => 2457,
193
            '17-03-31' => 1862,
194
            '17-04-30' => 1862,
195
            '17-05-31' => 1862,
196
            '17-06-30' => 1862,
197
            '17-07-31' => 1862,
198
            '17-08-31' => 1862,
199
            '17-09-30' => 1862,
200
            '17-10-31' => 1862,
201
            '17-11-30' => 1862,
202
            '17-12-31' => 1862,
203
            '18-01-31' => 1862,
204
            '18-02-28' => 1862,
205
            '18-03-31' => 1862,
206
            '18-04-30' => 1862,
207
            '18-05-31' => 1862,
208
            '18-06-30' => 1862,
209
            '18-07-31' => 1862,
210
            '18-08-31' => 1862,
211
            '18-09-30' => 1862,
212
            '18-10-31' => 1862,
213
            '18-11-30' => 1862,
214
            '18-12-31' => 1862,
215
            '19-01-31' => 1862,
216
            '19-02-28' => 1862,
217
            '19-03-31' => 1862,
218
            '19-04-30' => 1862,
219
            '19-05-31' => 1862,
220
            '19-06-30' => 1862,
221
            '19-07-31' => 1862,
222
            '19-08-31' => 1862,
223
            '19-09-30' => 1862,
224
            '19-10-31' => 1862,
225
            '19-11-30' => 1862,
226
            '19-12-31' => 1862,
227
            '20-01-31' => 1862,
228
            '20-02-29' => 1862,
229
            '20-03-31' => 1862,
230
            '20-04-30' => 1862,
231
            '20-05-31' => 1862,
232
            '20-06-30' => 1862,
233
            '20-07-31' => 1862,
234
            '20-08-31' => 1862,
235
            '20-09-30' => 1862,
236
            '20-10-31' => 1862,
237
            '20-11-30' => 1862,
238
            '20-12-31' => 1862,
239
            '21-01-31' => 1862,
240
            '21-02-28' => 1862,
241
            '21-03-31' => 1862,
242
            '21-04-30' => 1862,
243
            '21-05-31' => 1862,
244
            '21-06-30' => 1862,
245
            '21-07-31' => 1862,
246
            '21-08-31' => 1862,
247
            '21-09-30' => 1862,
248
            '21-10-31' => 1862,
249
            '21-11-30' => 1862,
250
            '21-12-31' => 1862,
251
            '22-01-31' => 1862,
252
            '22-02-28' => 1862,
253
            '22-03-31' => 1862,
254
            '22-04-30' => 1862,
255
            '22-05-31' => 1862,
256
            '22-06-30' => 1862,
257
            '22-07-31' => 1862,
258
            '22-08-31' => 1862,
259
            '22-09-30' => 1862,
260
            '22-10-31' => 1862,
261
            '22-11-30' => 1862,
262
            '22-12-31' => 1862,
263
            '23-01-31' => 1862,
264
        ];
265
    }
266
}
267