1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the prooph/php-ddd-cargo-sample. |
4
|
|
|
* (c) Alexander Miertsch <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
* |
9
|
|
|
* Date: 29.03.14 - 19:56 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace CodelinerTest\CargoBackend\Infrastructure\Routing; |
13
|
|
|
|
14
|
|
|
use Codeliner\CargoBackend\Infrastructure\Routing\ExternalRoutingService; |
15
|
|
|
use Codeliner\CargoBackend\Model\Cargo\RouteSpecification; |
16
|
|
|
use CodelinerTest\CargoBackend\Mock\GraphTraversalServiceMock; |
17
|
|
|
use CodelinerTest\CargoBackend\TestCase; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class ExternalRoutingServiceTest |
21
|
|
|
* |
22
|
|
|
* @package CodelinerTest\CargoBackend\Infrastructure\Routing |
23
|
|
|
* @author Alexander Miertsch <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class ExternalRoutingServiceTest extends TestCase |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var ExternalRoutingService |
29
|
|
|
*/ |
30
|
|
|
private $externalRoutingService; |
31
|
|
|
|
32
|
|
|
protected function setUp() |
33
|
|
|
{ |
34
|
|
|
$this->externalRoutingService = new ExternalRoutingService(new GraphTraversalServiceMock()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @test |
39
|
|
|
*/ |
40
|
|
|
public function it_fetches_routes_for_specification() |
41
|
|
|
{ |
42
|
|
|
$routeSpecification = new RouteSpecification('DEHAM', 'USNYC'); |
43
|
|
|
|
44
|
|
|
$itineraries = $this->externalRoutingService->fetchRoutesForSpecification($routeSpecification); |
45
|
|
|
|
46
|
|
|
$this->assertEquals(1, count($itineraries)); |
47
|
|
|
|
48
|
|
|
$itinerary = $itineraries[0]; |
49
|
|
|
|
50
|
|
|
$this->assertInstanceOf('Codeliner\CargoBackend\Model\Cargo\Itinerary', $itinerary); |
51
|
|
|
|
52
|
|
|
$legs = $itinerary->legs(); |
53
|
|
|
|
54
|
|
|
$this->assertEquals(1, count($legs)); |
55
|
|
|
|
56
|
|
|
$leg = $legs[0]; |
57
|
|
|
|
58
|
|
|
$this->assertInstanceOf('Codeliner\CargoBackend\Model\Cargo\Leg', $leg); |
59
|
|
|
|
60
|
|
|
$loadDate = new \DateTime('2014-03-29 19:59:23'); |
61
|
|
|
$unloadDate = new \DateTime('2014-03-30 21:30:00'); |
62
|
|
|
|
63
|
|
|
$this->assertEquals('DEHAM', $leg->loadLocation()); |
64
|
|
|
$this->assertEquals('USNYC', $leg->unloadLocation()); |
65
|
|
|
$this->assertEquals($loadDate->getTimestamp(), $leg->loadTime()->getTimestamp()); |
66
|
|
|
$this->assertEquals($unloadDate->getTimestamp(), $leg->unloadTime()->getTimestamp()); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|