|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
/** |
|
4
|
|
|
* Created by PhpStorm. |
|
5
|
|
|
* User: benedikt |
|
6
|
|
|
* Date: 10/1/17 |
|
7
|
|
|
* Time: 12:52 PM |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Tfboe\FmLib\Tests\Unit\Entity\Helpers; |
|
11
|
|
|
|
|
12
|
|
|
use Doctrine\Common\Collections\Collection; |
|
13
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
|
14
|
|
|
use Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity; |
|
15
|
|
|
use Tfboe\FmLib\Entity\RankingSystemInterface; |
|
16
|
|
|
use Tfboe\FmLib\Tests\Entity\RankingSystem; |
|
17
|
|
|
use Tfboe\FmLib\Tests\Helpers\UnitTestCase; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class BaseEntityTest |
|
21
|
|
|
* @package Tfboe\FmLib\Tests\Unit\Entity\Helpers |
|
22
|
|
|
*/ |
|
23
|
|
|
class TournamentHierarchyEntityTest extends UnitTestCase |
|
24
|
|
|
{ |
|
25
|
|
|
//<editor-fold desc="Public Methods"> |
|
26
|
|
|
/** |
|
27
|
|
|
* @covers \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::__construct |
|
28
|
|
|
* @uses \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::getRankingSystems |
|
29
|
|
|
*/ |
|
30
|
|
|
public function testConstructor() |
|
31
|
|
|
{ |
|
32
|
|
|
$entity = $this->entity(); |
|
33
|
|
|
self::assertInstanceOf(Collection::class, $entity->getRankingSystems()); |
|
|
|
|
|
|
34
|
|
|
self::assertEquals(0, $entity->getRankingSystems()->count()); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @covers \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::getRankingSystems |
|
39
|
|
|
* @uses \Tfboe\FmLib\Entity\Helpers\TournamentHierarchyEntity::__construct |
|
40
|
|
|
*/ |
|
41
|
|
|
public function testRankingSystems() |
|
42
|
|
|
{ |
|
43
|
|
|
$entity = $this->entity(); |
|
44
|
|
|
/** @var $system RankingSystemInterface */ |
|
45
|
|
|
$system = $this->createStubWithId(RankingSystem::class); |
|
46
|
|
|
$entity->getRankingSystems()->set($system->getId(), $system); |
|
|
|
|
|
|
47
|
|
|
self::assertEquals(1, $entity->getRankingSystems()->count()); |
|
48
|
|
|
self::assertEquals($system, $entity->getRankingSystems()[$system->getId()]); |
|
49
|
|
|
} |
|
50
|
|
|
//</editor-fold desc="Public Methods"> |
|
51
|
|
|
|
|
52
|
|
|
//<editor-fold desc="Private Methods"> |
|
53
|
|
|
/** |
|
54
|
|
|
* @return MockObject|TournamentHierarchyEntity |
|
55
|
|
|
*/ |
|
56
|
|
|
private function entity(): MockObject |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->getMockForAbstractClass(TournamentHierarchyEntity::class); |
|
59
|
|
|
} |
|
60
|
|
|
//</editor-fold desc="Private Methods"> |
|
61
|
|
|
} |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: