CurrentApiCallFactoryTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
lcom 1
cbo 5
dl 0
loc 56
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testCreate() 0 30 1
A setUp() 0 12 1
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