|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* Created by PhpStorm. |
|
5
|
|
|
* User: benedikt |
|
6
|
|
|
* Date: 10/1/17 |
|
7
|
|
|
* Time: 1:11 PM |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Tfboe\FmLib\Tests\Unit\Entity\Helpers; |
|
11
|
|
|
|
|
12
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
13
|
|
|
use Tfboe\FmLib\Entity\Helpers\NumericalId; |
|
14
|
|
|
use Tfboe\FmLib\Tests\Helpers\UnitTestCase; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class PlayerTest |
|
18
|
|
|
* @package Tfboe\FmLib\Tests\Unit\Entity |
|
19
|
|
|
*/ |
|
20
|
|
|
class NumericalIdTest extends UnitTestCase |
|
21
|
|
|
{ |
|
22
|
|
|
//<editor-fold desc="Public Methods"> |
|
23
|
|
|
/** |
|
24
|
|
|
* @covers \Tfboe\FmLib\Entity\Helpers\NumericalId::getId |
|
25
|
|
|
*/ |
|
26
|
|
View Code Duplication |
public function testId() |
|
|
|
|
|
|
27
|
|
|
{ |
|
28
|
|
|
$player = $this->player(); |
|
29
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
|
30
|
|
|
$idProperty = self::getProperty(get_class($player), 'id'); |
|
31
|
|
|
$idProperty->setValue($player, 0); |
|
32
|
|
|
self::assertEquals(0, $player->getId()); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @covers \Tfboe\FmLib\Entity\Helpers\NumericalId::getEntityId |
|
37
|
|
|
*/ |
|
38
|
|
View Code Duplication |
public function testEntityId() |
|
|
|
|
|
|
39
|
|
|
{ |
|
40
|
|
|
$player = $this->player(); |
|
41
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
|
42
|
|
|
$idProperty = self::getProperty(get_class($player), 'id'); |
|
43
|
|
|
$idProperty->setValue($player, 1); |
|
44
|
|
|
self::assertEquals(1, $player->getEntityId()); |
|
|
|
|
|
|
45
|
|
|
} |
|
46
|
|
|
//</editor-fold desc="Public Methods"> |
|
47
|
|
|
|
|
48
|
|
|
//<editor-fold desc="Private Methods"> |
|
49
|
|
|
/** |
|
50
|
|
|
* @return NumericalId|MockObject a new player |
|
51
|
|
|
*/ |
|
52
|
|
|
private function player(): MockObject |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->getMockForTrait(NumericalId::class); |
|
55
|
|
|
} |
|
56
|
|
|
//</editor-fold desc="Private Methods"> |
|
57
|
|
|
} |
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.