PlanetaryColonyTest::assertPin()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 21
rs 9.3142
c 2
b 0
f 0
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
namespace Tarioch\EveapiFetcherBundle\Tests\Functional\Api\Corp;
3
4
use Tarioch\EveapiFetcherBundle\Tests\Functional\AbstractFunctionalTestCase;
5
use Tarioch\EveapiFetcherBundle\Entity\ApiCall;
6
use Tarioch\EveapiFetcherBundle\Entity\ApiKey;
7
use Tarioch\EveapiFetcherBundle\Entity\AccountCharacter;
8
use Tarioch\EveapiFetcherBundle\Component\EveApi\Char\PlanetaryColonyUpdater;
9
use Pheal\Pheal;
10
11
class PlanetaryColonyTest extends AbstractFunctionalTestCase
12
{
13
    private $api;
14
    private $pheal;
15
16
    public function testUpdate()
17
    {
18
        $key = new ApiKey(123, 'dummyvcode');
19
        $owner = new AccountCharacter($key, 11);
20
        $call = new ApiCall('dummyapi', $owner, $key);
21
        $this->api->update($call, $key, $this->pheal);
22
        $this->entityManager->flush();
23
24
        $this->assertColony();
25
        $this->assertPin();
26
        $this->assertLink();
27
        $this->assertRoute();
28
    }
29
30
    private function assertColony()
31
    {
32
        $repo = $this->entityManager->getRepository('TariochEveapiFetcherBundle:CharPlanetaryColony');
33
        $colony = $repo->findOneByPlanetId(42);
34
35
        $this->assertEquals(11, $colony->getOwnerId());
36
        $this->assertEquals('OwnerName', $colony->getOwnerName());
37
        $this->assertEquals(22, $colony->getSolarSystemId());
38
        $this->assertEquals('SolarSystemName', $colony->getSolarSystemName());
39
        $this->assertEquals('PlanetName', $colony->getPlanetName());
40
        $this->assertEquals(33, $colony->getPlanetTypeId());
41
        $this->assertEquals('PlanetTypeName', $colony->getPlanetTypeName());
42
        $this->assertEquals(new \DateTime('2010-10-15 22:33:44'), $colony->getLastUpdate());
43
        $this->assertEquals(44, $colony->getUpgradeLevel());
44
        $this->assertEquals(55, $colony->getNumberOfPins());
45
    }
46
47
    private function assertPin()
48
    {
49
        $repo = $this->entityManager->getRepository('TariochEveapiFetcherBundle:CharPlanetaryPin');
50
        $pin = $repo->findOneByPlanetId(42);
51
52
        $this->assertEquals(11, $pin->getOwnerId());
53
        $this->assertEquals(88, $pin->getPinId());
54
        $this->assertEquals(22, $pin->getTypeId());
55
        $this->assertEquals('TypeName', $pin->getTypeName());
56
        $this->assertEquals(33, $pin->getSchematicId());
57
        $this->assertEquals(new \DateTime('2010-10-15 22:33:44'), $pin->getLastLaunchTime());
58
        $this->assertEquals(44, $pin->getCycleTime());
59
        $this->assertEquals(55, $pin->getQuantityPerCycle());
60
        $this->assertEquals(new \DateTime('2011-12-25 12:13:14'), $pin->getInstallTime());
61
        $this->assertEquals(new \DateTime('2012-12-16 13:14:15'), $pin->getExpiryTime());
62
        $this->assertEquals(66, $pin->getContentTypeId());
63
        $this->assertEquals('ContentTypeName', $pin->getContentTypeName());
64
        $this->assertEquals(77, $pin->getContentQuantity());
65
        $this->assertEquals(-1.11, $pin->getLongitude());
66
        $this->assertEquals(2.22, $pin->getLatitude());
67
    }
68
69
    private function assertLink()
70
    {
71
        $repo = $this->entityManager->getRepository('TariochEveapiFetcherBundle:CharPlanetaryLink');
72
        $link = $repo->findOneByPlanetId(42);
73
74
        $this->assertEquals(11, $link->getOwnerId());
75
        $this->assertEquals(22, $link->getSourcePinId());
76
        $this->assertEquals(33, $link->getDestinationPinId());
77
        $this->assertEquals(44, $link->getLinkLevel());
78
    }
79
80
    private function assertRoute()
81
    {
82
        $repo = $this->entityManager->getRepository('TariochEveapiFetcherBundle:CharPlanetaryRoute');
83
        $route = $repo->findOneByPlanetId(42);
84
85
        $this->assertEquals(11, $route->getOwnerId());
86
        $this->assertEquals(22, $route->getRouteId());
87
        $this->assertEquals(33, $route->getSourcePinId());
88
        $this->assertEquals(44, $route->getDestinationPinId());
89
        $this->assertEquals(55, $route->getContentTypeId());
90
        $this->assertEquals('ContentTypeName', $route->getContentTypeName());
91
        $this->assertEquals(66, $route->getQuantity());
92
        $this->assertEquals(77, $route->getWaypoint1());
93
        $this->assertEquals(88, $route->getWaypoint2());
94
        $this->assertEquals(99, $route->getWaypoint3());
95
        $this->assertEquals(122, $route->getWaypoint4());
96
        $this->assertEquals(133, $route->getWaypoint5());
97
    }
98
99
    public function setUp()
100
    {
101
        parent::setUp();
102
        $this->api = new PlanetaryColonyUpdater($this->entityManager);
103
        $this->pheal = new Pheal(123, 'dummyvcode');
104
    }
105
}
106