CurrentApiCallFactoryTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
namespace Tarioch\EveapiFetcherBundle\Tests\Unit\Component\EveApi\Account\ApiKeyInfo;
3
4
use Mockery as m;
5
use Tarioch\EveapiFetcherBundle\Entity\Api;
6
use Tarioch\EveapiFetcherBundle\Component\EveApi\Account\ApiKeyInfo\CurrentApiCallFactory;
7
8
class CurrentApiCallFactoryTest extends \PHPUnit_Framework_TestCase
9
{
10
    private $entityManager;
11
    private $repository;
12
    private $apiKey;
13
    private $apiCall1;
14
    private $apiCall2;
15
    private $api;
16
    private $owner1;
17
18
    private $factory;
19
20
    public function testCreate()
21
    {
22
        $apiId = 'apiId';
23
        $ownerId1 = 'ownerId1';
24
25
        $expected = array($apiId => array(
26
            $ownerId1 => $this->apiCall1,
27
            0 => $this->apiCall2
28
        ));
29
30
        $this->entityManager->shouldReceive('getRepository')
31
            ->with('TariochEveapiFetcherBundle:ApiCall')
32
            ->andReturn($this->repository);
33
        $this->repository->shouldReceive('findNormalCallsByKey')
34
            ->with($this->apiKey)
35
            ->andReturn(array($this->apiCall1, $this->apiCall2));
36
        $this->api->shouldReceive('getApiId')->andReturn($apiId);
37
38
        $this->apiCall1->shouldReceive('getApi')->andReturn($this->api);
39
        $this->apiCall1->shouldReceive('getOwner')->andReturn($this->owner1);
40
        $this->owner1->shouldReceive('getId')->andReturn($ownerId1);
41
42
        $this->apiCall2->shouldReceive('getApi')->andReturn($this->api);
43
        $this->apiCall2->shouldReceive('getOwner')->andReturn(null);
44
45
46
        $actual = $this->factory->createCurrentApiCallMap($this->apiKey);
47
48
        $this->assertEquals($expected, $actual);
49
    }
50
51
    protected function setUp()
52
    {
53
        $this->entityManager = m::mock('Doctrine\ORM\EntityManager');
54
        $this->repository = m::mock('Tarioch\EveapiFetcherBundle\Entity\ApiCallRepository');
55
        $this->apiKey = m::mock('Tarioch\EveapiFetcherBundle\Entity\ApiKey');
56
        $this->apiCall1 = m::mock('Tarioch\EveapiFetcherBundle\Entity\ApiCall');
57
        $this->apiCall2 = m::mock('Tarioch\EveapiFetcherBundle\Entity\ApiCall');
58
        $this->api = m::mock('Tarioch\EveapiFetcherBundle\Entity\Api');
59
        $this->owner1 = m::mock('Tarioch\EveapiFetcherBundle\Entity\AccountCharacter');
60
61
        $this->factory = new CurrentApiCallFactory($this->entityManager);
62
    }
63
}
64