PlayerSkillsTest::testSetValuesOverLimit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 21

Duplication

Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
dl 23
loc 23
rs 9.0856
c 0
b 0
f 0
cc 1
eloc 21
nc 1
nop 0
1
<?php
2
3
namespace OSS\CoreBundle\Tests\Entity;
4
5
use OSS\CoreBundle\Entity\Player;
6
use OSS\CoreBundle\Entity\PlayerSkills;
7
8
class PlayerSkillsTest extends \PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @var PlayerSkills
12
     */
13
    private $playerSkills;
14
15
    public function setUp()
16
    {
17
        $this->playerSkills = new PlayerSkills();
18
    }
19
20
    public function tearDown()
21
    {
22
        $this->playerSkills = null;
23
    }
24
25 View Code Duplication
    public function testBaseValues()
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...
26
    {
27
        $this->assertEquals(1, $this->playerSkills->getTackling());
28
        $this->assertEquals(1, $this->playerSkills->getPassing());
29
        $this->assertEquals(1, $this->playerSkills->getShooting());
30
        $this->assertEquals(1, $this->playerSkills->getHeading());
31
        $this->assertEquals(1, $this->playerSkills->getSpeed());
32
        $this->assertEquals(1, $this->playerSkills->getCrossing());
33
        $this->assertEquals(1, $this->playerSkills->getTechnics());
34
        $this->assertEquals(1, $this->playerSkills->getIntelligence());
35
        $this->assertEquals(1, $this->playerSkills->getSafety());
36
        $this->assertEquals(1, $this->playerSkills->getDribbling());
37
    }
38
    
39 View Code Duplication
    public function testSetValues()
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...
40
    {
41
        $this->playerSkills->setTackling(10);
42
        $this->assertEquals(10, $this->playerSkills->getTackling());
43
        $this->playerSkills->setPassing(10);
44
        $this->assertEquals(10, $this->playerSkills->getPassing());
45
        $this->playerSkills->setShooting(10);
46
        $this->assertEquals(10, $this->playerSkills->getShooting());
47
        $this->playerSkills->setHeading(10);
48
        $this->assertEquals(10, $this->playerSkills->getHeading());
49
        $this->playerSkills->setSpeed(10);
50
        $this->assertEquals(10, $this->playerSkills->getSpeed());
51
        $this->playerSkills->setCrossing(10);
52
        $this->assertEquals(10, $this->playerSkills->getCrossing());
53
        $this->playerSkills->setTechnics(10);
54
        $this->assertEquals(10, $this->playerSkills->getTechnics());
55
        $this->playerSkills->setIntelligence(10);
56
        $this->assertEquals(10, $this->playerSkills->getIntelligence());
57
        $this->playerSkills->setSafety(10);
58
        $this->assertEquals(10, $this->playerSkills->getSafety());
59
        $this->playerSkills->setDribbling(10);
60
        $this->assertEquals(10, $this->playerSkills->getDribbling());
61
    }
62
    
63 View Code Duplication
    public function testSetValuesOverLimit()
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...
64
    {
65
        $this->playerSkills->setTackling(110);
66
        $this->assertEquals(100, $this->playerSkills->getTackling());
67
        $this->playerSkills->setPassing(110);
68
        $this->assertEquals(100, $this->playerSkills->getPassing());
69
        $this->playerSkills->setShooting(110);
70
        $this->assertEquals(100, $this->playerSkills->getShooting());
71
        $this->playerSkills->setHeading(110);
72
        $this->assertEquals(100, $this->playerSkills->getHeading());
73
        $this->playerSkills->setSpeed(110);
74
        $this->assertEquals(100, $this->playerSkills->getSpeed());
75
        $this->playerSkills->setCrossing(110);
76
        $this->assertEquals(100, $this->playerSkills->getCrossing());
77
        $this->playerSkills->setTechnics(110);
78
        $this->assertEquals(100, $this->playerSkills->getTechnics());
79
        $this->playerSkills->setIntelligence(110);
80
        $this->assertEquals(100, $this->playerSkills->getIntelligence());
81
        $this->playerSkills->setSafety(110);
82
        $this->assertEquals(100, $this->playerSkills->getSafety());
83
        $this->playerSkills->setDribbling(110);
84
        $this->assertEquals(100, $this->playerSkills->getDribbling());
85
    }
86
    
87 View Code Duplication
    public function testSetValuesUnderLimit()
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...
88
    {
89
        $this->playerSkills->setTackling(0);
90
        $this->assertEquals(1, $this->playerSkills->getTackling());
91
        $this->playerSkills->setPassing(0);
92
        $this->assertEquals(1, $this->playerSkills->getPassing());
93
        $this->playerSkills->setShooting(0);
94
        $this->assertEquals(1, $this->playerSkills->getShooting());
95
        $this->playerSkills->setHeading(0);
96
        $this->assertEquals(1, $this->playerSkills->getHeading());
97
        $this->playerSkills->setSpeed(0);
98
        $this->assertEquals(1, $this->playerSkills->getSpeed());
99
        $this->playerSkills->setCrossing(0);
100
        $this->assertEquals(1, $this->playerSkills->getCrossing());
101
        $this->playerSkills->setTechnics(0);
102
        $this->assertEquals(1, $this->playerSkills->getTechnics());
103
        $this->playerSkills->setIntelligence(0);
104
        $this->assertEquals(1, $this->playerSkills->getIntelligence());
105
        $this->playerSkills->setSafety(0);
106
        $this->assertEquals(1, $this->playerSkills->getSafety());
107
        $this->playerSkills->setDribbling(0);
108
        $this->assertEquals(1, $this->playerSkills->getDribbling());
109
    }
110
    
111 View Code Duplication
    public function testIncreaseValues()
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...
112
    {
113
        $this->playerSkills->increaseTackling(10);
114
        $this->assertEquals(11, $this->playerSkills->getTackling());
115
        $this->playerSkills->increasePassing(10);
116
        $this->assertEquals(11, $this->playerSkills->getPassing());
117
        $this->playerSkills->increaseShooting(10);
118
        $this->assertEquals(11, $this->playerSkills->getShooting());
119
        $this->playerSkills->increaseHeading(10);
120
        $this->assertEquals(11, $this->playerSkills->getHeading());
121
        $this->playerSkills->increaseSpeed(10);
122
        $this->assertEquals(11, $this->playerSkills->getSpeed());
123
        $this->playerSkills->increaseCrossing(10);
124
        $this->assertEquals(11, $this->playerSkills->getCrossing());
125
        $this->playerSkills->increaseTechnics(10);
126
        $this->assertEquals(11, $this->playerSkills->getTechnics());
127
        $this->playerSkills->increaseIntelligence(10);
128
        $this->assertEquals(11, $this->playerSkills->getIntelligence());
129
        $this->playerSkills->increaseSafety(10);
130
        $this->assertEquals(11, $this->playerSkills->getSafety());
131
        $this->playerSkills->increaseDribbling(10);
132
        $this->assertEquals(11, $this->playerSkills->getDribbling());
133
    }
134
    
135 View Code Duplication
    public function testIncreaseValuesOverLimit()
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...
136
    {
137
        $this->playerSkills->increaseTackling(110);
138
        $this->assertEquals(100, $this->playerSkills->getTackling());
139
        $this->playerSkills->increasePassing(110);
140
        $this->assertEquals(100, $this->playerSkills->getPassing());
141
        $this->playerSkills->increaseShooting(110);
142
        $this->assertEquals(100, $this->playerSkills->getShooting());
143
        $this->playerSkills->increaseHeading(110);
144
        $this->assertEquals(100, $this->playerSkills->getHeading());
145
        $this->playerSkills->increaseSpeed(110);
146
        $this->assertEquals(100, $this->playerSkills->getSpeed());
147
        $this->playerSkills->increaseCrossing(110);
148
        $this->assertEquals(100, $this->playerSkills->getCrossing());
149
        $this->playerSkills->increaseTechnics(110);
150
        $this->assertEquals(100, $this->playerSkills->getTechnics());
151
        $this->playerSkills->increaseIntelligence(110);
152
        $this->assertEquals(100, $this->playerSkills->getIntelligence());
153
        $this->playerSkills->increaseSafety(110);
154
        $this->assertEquals(100, $this->playerSkills->getSafety());
155
        $this->playerSkills->increaseDribbling(110);
156
        $this->assertEquals(100, $this->playerSkills->getDribbling());
157
    }
158
    
159 View Code Duplication
    public function testIncreaseValuesUnderLimit()
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...
160
    {
161
        $this->playerSkills->increaseTackling(-1);
162
        $this->assertEquals(1, $this->playerSkills->getTackling());
163
        $this->playerSkills->increasePassing(-1);
164
        $this->assertEquals(1, $this->playerSkills->getPassing());
165
        $this->playerSkills->increaseShooting(-1);
166
        $this->assertEquals(1, $this->playerSkills->getShooting());
167
        $this->playerSkills->increaseHeading(-1);
168
        $this->assertEquals(1, $this->playerSkills->getHeading());
169
        $this->playerSkills->increaseSpeed(-1);
170
        $this->assertEquals(1, $this->playerSkills->getSpeed());
171
        $this->playerSkills->increaseCrossing(-1);
172
        $this->assertEquals(1, $this->playerSkills->getCrossing());
173
        $this->playerSkills->increaseTechnics(-1);
174
        $this->assertEquals(1, $this->playerSkills->getTechnics());
175
        $this->playerSkills->increaseIntelligence(-1);
176
        $this->assertEquals(1, $this->playerSkills->getIntelligence());
177
        $this->playerSkills->increaseSafety(-1);
178
        $this->assertEquals(1, $this->playerSkills->getSafety());
179
        $this->playerSkills->increaseDribbling(-1);
180
        $this->assertEquals(1, $this->playerSkills->getDribbling());
181
    }
182
183
    public function testDecreaseValues()
184
    {
185
        $this->playerSkills->setTackling(50);
186
        $this->playerSkills->decreaseTackling(10);
187
        $this->assertEquals(40, $this->playerSkills->getTackling());
188
        $this->playerSkills->setPassing(50);
189
        $this->playerSkills->decreasePassing(10);
190
        $this->assertEquals(40, $this->playerSkills->getPassing());
191
        $this->playerSkills->setShooting(50);
192
        $this->playerSkills->decreaseShooting(10);
193
        $this->assertEquals(40, $this->playerSkills->getShooting());
194
        $this->playerSkills->setHeading(50);
195
        $this->playerSkills->decreaseHeading(10);
196
        $this->assertEquals(40, $this->playerSkills->getHeading());
197
        $this->playerSkills->setSpeed(50);
198
        $this->playerSkills->decreaseSpeed(10);
199
        $this->assertEquals(40, $this->playerSkills->getSpeed());
200
        $this->playerSkills->setCrossing(50);
201
        $this->playerSkills->decreaseCrossing(10);
202
        $this->assertEquals(40, $this->playerSkills->getCrossing());
203
        $this->playerSkills->setTechnics(50);
204
        $this->playerSkills->decreaseTechnics(10);
205
        $this->assertEquals(40, $this->playerSkills->getTechnics());
206
        $this->playerSkills->setIntelligence(50);
207
        $this->playerSkills->decreaseIntelligence(10);
208
        $this->assertEquals(40, $this->playerSkills->getIntelligence());
209
        $this->playerSkills->setSafety(50);
210
        $this->playerSkills->decreaseSafety(10);
211
        $this->assertEquals(40, $this->playerSkills->getSafety());
212
        $this->playerSkills->setDribbling(50);
213
        $this->playerSkills->decreaseDribbling(10);
214
        $this->assertEquals(40, $this->playerSkills->getDribbling());
215
    }
216
    
217 View Code Duplication
    public function testDecreaseValuesOverLimit()
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...
218
    {
219
        $this->playerSkills->decreaseTackling(-100);
220
        $this->assertEquals(100, $this->playerSkills->getTackling());
221
        $this->playerSkills->decreasePassing(-100);
222
        $this->assertEquals(100, $this->playerSkills->getPassing());
223
        $this->playerSkills->decreaseShooting(-100);
224
        $this->assertEquals(100, $this->playerSkills->getShooting());
225
        $this->playerSkills->decreaseHeading(-100);
226
        $this->assertEquals(100, $this->playerSkills->getHeading());
227
        $this->playerSkills->decreaseSpeed(-100);
228
        $this->assertEquals(100, $this->playerSkills->getSpeed());
229
        $this->playerSkills->decreaseCrossing(-100);
230
        $this->assertEquals(100, $this->playerSkills->getCrossing());
231
        $this->playerSkills->decreaseTechnics(-100);
232
        $this->assertEquals(100, $this->playerSkills->getTechnics());
233
        $this->playerSkills->decreaseIntelligence(-100);
234
        $this->assertEquals(100, $this->playerSkills->getIntelligence());
235
        $this->playerSkills->decreaseSafety(-100);
236
        $this->assertEquals(100, $this->playerSkills->getSafety());
237
        $this->playerSkills->decreaseDribbling(-100);
238
        $this->assertEquals(100, $this->playerSkills->getDribbling());
239
    }
240
241 View Code Duplication
    public function testDecreaseValuesUnderLimit()
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...
242
    {
243
        $this->playerSkills->decreaseTackling(1);
244
        $this->assertEquals(1, $this->playerSkills->getTackling());
245
        $this->playerSkills->decreasePassing(1);
246
        $this->assertEquals(1, $this->playerSkills->getPassing());
247
        $this->playerSkills->decreaseShooting(1);
248
        $this->assertEquals(1, $this->playerSkills->getShooting());
249
        $this->playerSkills->decreaseHeading(1);
250
        $this->assertEquals(1, $this->playerSkills->getHeading());
251
        $this->playerSkills->decreaseSpeed(1);
252
        $this->assertEquals(1, $this->playerSkills->getSpeed());
253
        $this->playerSkills->decreaseCrossing(1);
254
        $this->assertEquals(1, $this->playerSkills->getCrossing());
255
        $this->playerSkills->decreaseTechnics(1);
256
        $this->assertEquals(1, $this->playerSkills->getTechnics());
257
        $this->playerSkills->decreaseIntelligence(1);
258
        $this->assertEquals(1, $this->playerSkills->getIntelligence());
259
        $this->playerSkills->decreaseSafety(1);
260
        $this->assertEquals(1, $this->playerSkills->getSafety());
261
        $this->playerSkills->decreaseDribbling(1);
262
        $this->assertEquals(1, $this->playerSkills->getDribbling());
263
    }
264
    
265
    public function testInitRandomValues()
266
    {
267
        $this->playerSkills->initWithRandomValues();
268
        $this->assertBetween(1, 100, $this->playerSkills->getTackling());
269
        $this->assertBetween(1, 100, $this->playerSkills->getPassing());
270
        $this->assertBetween(1, 100, $this->playerSkills->getShooting());
271
        $this->assertBetween(1, 100, $this->playerSkills->getHeading());
272
        $this->assertBetween(1, 100, $this->playerSkills->getSpeed());
273
        $this->assertBetween(1, 100, $this->playerSkills->getCrossing());
274
        $this->assertBetween(1, 100, $this->playerSkills->getTechnics());
275
        $this->assertBetween(1, 100, $this->playerSkills->getIntelligence());
276
        $this->assertBetween(1, 100, $this->playerSkills->getSafety());
277
        $this->assertBetween(1, 100, $this->playerSkills->getDribbling());
278
    }
279
280
    public function testSetPlayer()
281
    {
282
        $player = new Player();
283
        $this->playerSkills->setPlayer($player);
284
        $this->assertEquals($player, $this->playerSkills->getPlayer());
285
        $this->assertEquals($this->playerSkills, $player->getSkills());
286
    }
287
288
    public function testAverage()
289
    {
290
        $this->playerSkills->setAll(10);
291
        $this->playerSkills->setDribbling(60);
292
        $this->assertEquals(15, $this->playerSkills->getAverage());
293
    }
294
295 View Code Duplication
    public function testSetAll()
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...
296
    {
297
        $this->playerSkills->setAll(10);
298
        $this->assertEquals(10, $this->playerSkills->getTackling());
299
        $this->assertEquals(10, $this->playerSkills->getPassing());
300
        $this->assertEquals(10, $this->playerSkills->getShooting());
301
        $this->assertEquals(10, $this->playerSkills->getHeading());
302
        $this->assertEquals(10, $this->playerSkills->getSpeed());
303
        $this->assertEquals(10, $this->playerSkills->getCrossing());
304
        $this->assertEquals(10, $this->playerSkills->getTechnics());
305
        $this->assertEquals(10, $this->playerSkills->getIntelligence());
306
        $this->assertEquals(10, $this->playerSkills->getSafety());
307
        $this->assertEquals(10, $this->playerSkills->getDribbling());
308
    }
309
310
    public function testSetAllTrainingValues()
311
    {
312
        $this->playerSkills->setAllTrainingValues(10);
313
        $this->assertEquals(10, $this->playerSkills->getTrainingValueTackling());
314
        $this->assertEquals(10, $this->playerSkills->getTrainingValuePassing());
315
        $this->assertEquals(10, $this->playerSkills->getTrainingValueShooting());
316
        $this->assertEquals(10, $this->playerSkills->getTrainingValueHeading());
317
        $this->assertEquals(10, $this->playerSkills->getTrainingValueSpeed());
318
        $this->assertEquals(10, $this->playerSkills->getTrainingValueCrossing());
319
        $this->assertEquals(10, $this->playerSkills->getTrainingValueTechnics());
320
        $this->assertEquals(10, $this->playerSkills->getTrainingValueIntelligence());
321
        $this->assertEquals(10, $this->playerSkills->getTrainingValueSafety());
322
        $this->assertEquals(10, $this->playerSkills->getTrainingValueDribbling());
323
    }
324
325
    public function testCompareAverageSkill()
326
    {
327
        $this->playerSkills->setAll(50);
328
329
        $compareSkills = new PlayerSkills();
330
        $compareSkills->setAll(60);
331
        $this->assertTrue(PlayerSkills::compareAverage($this->playerSkills, $compareSkills));
332
333
        $compareSkills = new PlayerSkills();
334
        $compareSkills->setAll(50);
335
        $this->assertFalse(PlayerSkills::compareAverage($this->playerSkills, $compareSkills));
336
337
        $compareSkills = new PlayerSkills();
338
        $compareSkills->setAll(40);
339
        $this->assertFalse(PlayerSkills::compareAverage($this->playerSkills, $compareSkills));
340
    }
341
342
    public function testMarketValue()
343
    {
344
        $this->playerSkills->setAll(10);
345
        $this->assertEquals(100, $this->playerSkills->getMarketValue());
346
347
        $this->playerSkills->setAll(50);
348
        $this->assertEquals(1562500, $this->playerSkills->getMarketValue());
349
350
        $this->playerSkills->setAll(100);
351
        $this->assertEquals(100000000, $this->playerSkills->getMarketValue());
352
    }
353
354
    public function testGetTrainingValues()
355
    {
356
        $this->assertEquals(0, $this->playerSkills->getTrainingValueTackling());
357
        $this->assertEquals(0, $this->playerSkills->getTrainingValuePassing());
358
        $this->assertEquals(0, $this->playerSkills->getTrainingValueShooting());
359
        $this->assertEquals(0, $this->playerSkills->getTrainingValueHeading());
360
        $this->assertEquals(0, $this->playerSkills->getTrainingValueSpeed());
361
        $this->assertEquals(0, $this->playerSkills->getTrainingValueCrossing());
362
        $this->assertEquals(0, $this->playerSkills->getTrainingValueTechnics());
363
        $this->assertEquals(0, $this->playerSkills->getTrainingValueIntelligence());
364
        $this->assertEquals(0, $this->playerSkills->getTrainingValueSafety());
365
        $this->assertEquals(0, $this->playerSkills->getTrainingValueDribbling());
366
    }
367
368 View Code Duplication
    public function testSetAndGetTrainingValues()
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...
369
    {
370
        $this->playerSkills->setTrainingValueTackling(50);
371
        $this->assertEquals(50, $this->playerSkills->getTrainingValueTackling());
372
        $this->playerSkills->setTrainingValuePassing(50);
373
        $this->assertEquals(50, $this->playerSkills->getTrainingValuePassing());
374
        $this->playerSkills->setTrainingValueShooting(50);
375
        $this->assertEquals(50, $this->playerSkills->getTrainingValueShooting());
376
        $this->playerSkills->setTrainingValueHeading(50);
377
        $this->assertEquals(50, $this->playerSkills->getTrainingValueHeading());
378
        $this->playerSkills->setTrainingValueSpeed(50);
379
        $this->assertEquals(50, $this->playerSkills->getTrainingValueSpeed());
380
        $this->playerSkills->setTrainingValueCrossing(50);
381
        $this->assertEquals(50, $this->playerSkills->getTrainingValueCrossing());
382
        $this->playerSkills->setTrainingValueTechnics(50);
383
        $this->assertEquals(50, $this->playerSkills->getTrainingValueTechnics());
384
        $this->playerSkills->setTrainingValueIntelligence(50);
385
        $this->assertEquals(50, $this->playerSkills->getTrainingValueIntelligence());
386
        $this->playerSkills->setTrainingValueSafety(50);
387
        $this->assertEquals(50, $this->playerSkills->getTrainingValueSafety());
388
        $this->playerSkills->setTrainingValueDribbling(50);
389
        $this->assertEquals(50, $this->playerSkills->getTrainingValueDribbling());
390
    }
391
392 View Code Duplication
    public function testAddTrainingValues()
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...
393
    {
394
        $this->playerSkills->addTrainingValueTackling(50);
395
        $this->assertEquals(50, $this->playerSkills->getTrainingValueTackling());
396
        $this->playerSkills->addTrainingValuePassing(50);
397
        $this->assertEquals(50, $this->playerSkills->getTrainingValuePassing());
398
        $this->playerSkills->addTrainingValueShooting(50);
399
        $this->assertEquals(50, $this->playerSkills->getTrainingValueShooting());
400
        $this->playerSkills->addTrainingValueHeading(50);
401
        $this->assertEquals(50, $this->playerSkills->getTrainingValueHeading());
402
        $this->playerSkills->addTrainingValueSpeed(50);
403
        $this->assertEquals(50, $this->playerSkills->getTrainingValueSpeed());
404
        $this->playerSkills->addTrainingValueCrossing(50);
405
        $this->assertEquals(50, $this->playerSkills->getTrainingValueCrossing());
406
        $this->playerSkills->addTrainingValueTechnics(50);
407
        $this->assertEquals(50, $this->playerSkills->getTrainingValueTechnics());
408
        $this->playerSkills->addTrainingValueIntelligence(50);
409
        $this->assertEquals(50, $this->playerSkills->getTrainingValueIntelligence());
410
        $this->playerSkills->addTrainingValueSafety(50);
411
        $this->assertEquals(50, $this->playerSkills->getTrainingValueSafety());
412
        $this->playerSkills->addTrainingValueDribbling(50);
413
        $this->assertEquals(50, $this->playerSkills->getTrainingValueDribbling());
414
    }
415
416
    public function testTrainingValueReductionLow()
417
    {
418
        $this->playerSkills->setAllTrainingValues(20);
419
420
        $this->playerSkills->decreaseTrainingValues();
421
        $this->assertEquals(15, $this->playerSkills->getTrainingValueTackling());
422
        $this->assertEquals(15, $this->playerSkills->getTrainingValuePassing());
423
        $this->assertEquals(15, $this->playerSkills->getTrainingValueShooting());
424
        $this->assertEquals(15, $this->playerSkills->getTrainingValueHeading());
425
        $this->assertEquals(15, $this->playerSkills->getTrainingValueSpeed());
426
        $this->assertEquals(15, $this->playerSkills->getTrainingValueCrossing());
427
        $this->assertEquals(15, $this->playerSkills->getTrainingValueTechnics());
428
        $this->assertEquals(15, $this->playerSkills->getTrainingValueIntelligence());
429
        $this->assertEquals(15, $this->playerSkills->getTrainingValueSafety());
430
        $this->assertEquals(15, $this->playerSkills->getTrainingValueDribbling());
431
    }
432
433
    public function testTrainingValueAfterUpdateSkill()
434
    {
435
        $this->playerSkills->setAllTrainingValues(50);
436
        $this->playerSkills->updateSkills();
437
        $this->assertEquals(0, $this->playerSkills->getTrainingValueTackling());
438
        $this->assertEquals(0, $this->playerSkills->getTrainingValuePassing());
439
        $this->assertEquals(0, $this->playerSkills->getTrainingValueShooting());
440
        $this->assertEquals(0, $this->playerSkills->getTrainingValueHeading());
441
        $this->assertEquals(0, $this->playerSkills->getTrainingValueSpeed());
442
        $this->assertEquals(0, $this->playerSkills->getTrainingValueCrossing());
443
        $this->assertEquals(0, $this->playerSkills->getTrainingValueTechnics());
444
        $this->assertEquals(0, $this->playerSkills->getTrainingValueIntelligence());
445
        $this->assertEquals(0, $this->playerSkills->getTrainingValueSafety());
446
        $this->assertEquals(0, $this->playerSkills->getTrainingValueDribbling());
447
    }
448
449
    public function testUpdateSkillUp()
450
    {
451
        $this->playerSkills->setAll(20);
452
        $this->playerSkills->setAllTrainingValues(100);
453
454
        $this->playerSkills->updateSkills();
455
456
        $this->assertBetween(20, 30, $this->playerSkills->getTackling());
457
        $this->assertBetween(20, 30, $this->playerSkills->getPassing());
458
        $this->assertBetween(20, 30, $this->playerSkills->getShooting());
459
        $this->assertBetween(20, 30, $this->playerSkills->getHeading());
460
        $this->assertBetween(20, 30, $this->playerSkills->getSpeed());
461
        $this->assertBetween(20, 30, $this->playerSkills->getCrossing());
462
        $this->assertBetween(20, 30, $this->playerSkills->getTechnics());
463
        $this->assertBetween(20, 30, $this->playerSkills->getIntelligence());
464
        $this->assertBetween(20, 30, $this->playerSkills->getSafety());
465
        $this->assertBetween(20, 30, $this->playerSkills->getDribbling());
466
467
        $this->assertBetween(0, 10, $this->playerSkills->getChangeTackling());
468
        $this->assertBetween(0, 10, $this->playerSkills->getChangePassing());
469
        $this->assertBetween(0, 10, $this->playerSkills->getChangeShooting());
470
        $this->assertBetween(0, 10, $this->playerSkills->getChangeHeading());
471
        $this->assertBetween(0, 10, $this->playerSkills->getChangeSpeed());
472
        $this->assertBetween(0, 10, $this->playerSkills->getChangeCrossing());
473
        $this->assertBetween(0, 10, $this->playerSkills->getChangeTechnics());
474
        $this->assertBetween(0, 10, $this->playerSkills->getChangeIntelligence());
475
        $this->assertBetween(0, 10, $this->playerSkills->getChangeSafety());
476
        $this->assertBetween(0, 10, $this->playerSkills->getChangeDribbling());
477
    }
478
479
    public function testUpdateSkillDown()
480
    {
481
        $this->playerSkills->setAll(50);
482
        $this->playerSkills->setAllTrainingValues(-100);
483
484
        $this->playerSkills->updateSkills();
485
486
        $this->assertBetween(40, 50, $this->playerSkills->getTackling());
487
        $this->assertBetween(40, 50, $this->playerSkills->getPassing());
488
        $this->assertBetween(40, 50, $this->playerSkills->getShooting());
489
        $this->assertBetween(40, 50, $this->playerSkills->getHeading());
490
        $this->assertBetween(40, 50, $this->playerSkills->getSpeed());
491
        $this->assertBetween(40, 50, $this->playerSkills->getCrossing());
492
        $this->assertBetween(40, 50, $this->playerSkills->getTechnics());
493
        $this->assertBetween(40, 50, $this->playerSkills->getIntelligence());
494
        $this->assertBetween(40, 50, $this->playerSkills->getSafety());
495
        $this->assertBetween(40, 50, $this->playerSkills->getDribbling());
496
497
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeTackling());
498
        $this->assertBetween(-10, 0, $this->playerSkills->getChangePassing());
499
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeShooting());
500
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeHeading());
501
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeSpeed());
502
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeCrossing());
503
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeTechnics());
504
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeIntelligence());
505
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeSafety());
506
        $this->assertBetween(-10, 0, $this->playerSkills->getChangeDribbling());
507
    }
508
509
    /**
510
     * @param int $min
511
     * @param int $max
512
     * @param int $value
513
     */
514
    private function assertBetween($min, $max, $value)
515
    {
516
        $this->assertGreaterThanOrEqual($min, $value);
517
        $this->assertLessThanOrEqual($max, $value);
518
    }
519
}
520