1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
/** |
4
|
|
|
* Created by PhpStorm. |
5
|
|
|
* User: benedikt |
6
|
|
|
* Date: 10/1/17 |
7
|
|
|
* Time: 12:05 PM |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Tfboe\FmLib\Tests\Unit\Entity\CategoryTraits; |
11
|
|
|
|
12
|
|
|
use Tfboe\FmLib\Entity\Categories\TeamMode; |
13
|
|
|
use Tfboe\FmLib\Exceptions\ValueNotValid; |
14
|
|
|
use Tfboe\FmLib\Tests\Helpers\UnitTestCase; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class TeamModeTest |
18
|
|
|
* @package Tfboe\FmLib\Tests\Unit\Entity\CategoryTraits |
19
|
|
|
*/ |
20
|
|
View Code Duplication |
class TeamModeTest extends UnitTestCase |
|
|
|
|
21
|
|
|
{ |
22
|
|
|
//<editor-fold desc="Public Methods"> |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::getTeamMode |
26
|
|
|
* @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::setTeamMode |
27
|
|
|
* @uses \Tfboe\FmLib\Helpers\BasicEnum |
28
|
|
|
*/ |
29
|
|
|
public function testProperty() |
30
|
|
|
{ |
31
|
|
|
$mock = $this->mock(); |
32
|
|
|
self::assertNull($mock->getTeamMode()); |
33
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
34
|
|
|
$mock->setTeamMode(TeamMode::DOUBLE); |
35
|
|
|
self::assertEquals(TeamMode::DOUBLE, $mock->getTeamMode()); |
36
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
37
|
|
|
$mock->setTeamMode(null); |
38
|
|
|
self::assertNull($mock->getTeamMode()); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @covers \Tfboe\FmLib\Entity\CategoryTraits\TeamMode::setTeamMode |
43
|
|
|
* @uses \Tfboe\FmLib\Helpers\BasicEnum |
44
|
|
|
* @uses \Tfboe\FmLib\Exceptions\ValueNotValid::__construct |
45
|
|
|
*/ |
46
|
|
|
public function testPropertyException() |
47
|
|
|
{ |
48
|
|
|
$mock = $this->mock(); |
49
|
|
|
$this->expectException(ValueNotValid::class); |
50
|
|
|
$this->expectExceptionMessage( |
51
|
|
|
'The following value is not valid: 100 in Tfboe\FmLib\Entity\Categories\TeamMode. Possible values: 0, 1, 2.'); |
52
|
|
|
/** @noinspection PhpUnhandledExceptionInspection */ |
53
|
|
|
$mock->setTeamMode(100); |
54
|
|
|
} |
55
|
|
|
//</editor-fold desc="Public Methods"> |
56
|
|
|
|
57
|
|
|
//<editor-fold desc="Private Methods"> |
58
|
|
|
/** |
59
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject|\Tfboe\FmLib\Entity\CategoryTraits\TeamMode |
60
|
|
|
*/ |
61
|
|
|
private function mock(): \PHPUnit_Framework_MockObject_MockObject |
62
|
|
|
{ |
63
|
|
|
return $this->getMockForTrait(\Tfboe\FmLib\Entity\CategoryTraits\TeamMode::class); |
64
|
|
|
} |
65
|
|
|
//</editor-fold desc="Private Methods"> |
66
|
|
|
} |
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.