|
1
|
|
|
<?php |
|
2
|
|
|
namespace Tarioch\EveapiFetcherBundle\Tests\Unit\Component\EveApi\Account\ApiKeyInfo; |
|
3
|
|
|
|
|
4
|
|
|
use Mockery as m; |
|
5
|
|
|
use Tarioch\EveapiFetcherBundle\Component\EveApi\Account\ApiKeyInfo\NewApiFactory; |
|
6
|
|
|
|
|
7
|
|
|
class NewApiFactoryTest extends \PHPUnit_Framework_TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
private $entityManager; |
|
10
|
|
|
private $repository; |
|
11
|
|
|
private $api1; |
|
12
|
|
|
private $api2; |
|
13
|
|
|
|
|
14
|
|
|
private $factory; |
|
15
|
|
|
|
|
16
|
|
|
public function testCreate() |
|
17
|
|
|
{ |
|
18
|
|
|
$accessMask = 'accessMask'; |
|
19
|
|
|
$keyType = 'keyType'; |
|
20
|
|
|
$apiId1 = 'apiId1'; |
|
21
|
|
|
$apiId2 = 'apiId2'; |
|
22
|
|
|
$section1 = 'section1'; |
|
23
|
|
|
$ownerId1 = 'ownerId1'; |
|
24
|
|
|
$ownerId2 = 'ownerId2'; |
|
25
|
|
|
|
|
26
|
|
|
$expected = array( |
|
27
|
|
|
$apiId1 => array( |
|
28
|
|
|
$ownerId1 => $this->api1, |
|
29
|
|
|
$ownerId2 => $this->api1 |
|
30
|
|
|
), |
|
31
|
|
|
$apiId2 => array( |
|
32
|
|
|
0 => $this->api2 |
|
33
|
|
|
) |
|
34
|
|
|
); |
|
35
|
|
|
|
|
36
|
|
|
$this->entityManager->shouldReceive('getRepository') |
|
37
|
|
|
->with('TariochEveapiFetcherBundle:Api') |
|
38
|
|
|
->andReturn($this->repository); |
|
39
|
|
|
$this->repository->shouldReceive('loadValidApis') |
|
40
|
|
|
->with($accessMask, $keyType) |
|
41
|
|
|
->andReturn(array($this->api1, $this->api2)); |
|
42
|
|
|
|
|
43
|
|
|
$this->api1->shouldReceive('getApiId')->andReturn($apiId1); |
|
44
|
|
|
$this->api1->shouldReceive('getSection')->andReturn($section1); |
|
45
|
|
|
|
|
46
|
|
|
$this->api2->shouldReceive('getApiId')->andReturn($apiId2); |
|
47
|
|
|
$this->api2->shouldReceive('getSection')->andReturn('account'); |
|
48
|
|
|
|
|
49
|
|
|
$actual = $this->factory->createNewApiMap($accessMask, $keyType, array($ownerId1, $ownerId2)); |
|
50
|
|
|
|
|
51
|
|
|
$this->assertEquals($expected, $actual); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
protected function setUp() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->entityManager = m::mock('Doctrine\ORM\EntityManager'); |
|
57
|
|
|
$this->repository = m::mock('Tarioch\EveapiFetcherBundle\Entity\ApiRepository'); |
|
58
|
|
|
$this->api1 = m::mock('Tarioch\EveapiFetcherBundle\Entity\Api'); |
|
59
|
|
|
$this->api2 = m::mock('Tarioch\EveapiFetcherBundle\Entity\Api'); |
|
60
|
|
|
|
|
61
|
|
|
$this->factory = new NewApiFactory($this->entityManager); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|