1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the prooph/php-ddd-cargo-sample package. |
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
|
|
|
namespace CodelinerTest\CargoBackend\Domain\Model\Cargo; |
10
|
|
|
|
11
|
|
|
use Codeliner\CargoBackend\Model\Cargo\Itinerary; |
12
|
|
|
use CodelinerTest\CargoBackend\Fixture\LegFixture; |
13
|
|
|
use CodelinerTest\CargoBackend\TestCase; |
14
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
15
|
|
|
use Codeliner\CargoBackend\Model\Cargo\Leg; |
16
|
|
|
/** |
17
|
|
|
* Class ItineraryTest |
18
|
|
|
* |
19
|
|
|
* @author Alexander Miertsch <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class ItineraryTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @test |
25
|
|
|
*/ |
26
|
|
View Code Duplication |
public function it_has_list_of_legs() |
|
|
|
|
27
|
|
|
{ |
28
|
|
|
$legs = [LegFixture::get(LegFixture::HONGKONG_NEWYORK), LegFixture::get(LegFixture::NEWYORK_HAMBURG)]; |
29
|
|
|
|
30
|
|
|
$itinerary = new Itinerary($legs); |
|
|
|
|
31
|
|
|
|
32
|
|
|
$this->assertSame($legs, $itinerary->legs()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @test |
37
|
|
|
*/ |
38
|
|
View Code Duplication |
public function it_is_same_value_as_itinerary_with_same_legs() |
|
|
|
|
39
|
|
|
{ |
40
|
|
|
$legs = [LegFixture::get(LegFixture::HONGKONG_NEWYORK), LegFixture::get(LegFixture::NEWYORK_HAMBURG)]; |
41
|
|
|
|
42
|
|
|
$itinerary = new Itinerary($legs); |
|
|
|
|
43
|
|
|
$sameItinerary = new Itinerary($legs); |
|
|
|
|
44
|
|
|
|
45
|
|
|
$this->assertTrue($itinerary->sameValueAs($sameItinerary)); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @test |
50
|
|
|
*/ |
51
|
|
|
public function it_is_not_same_value_as_itinerary_with_other_list_of_legs() |
52
|
|
|
{ |
53
|
|
|
$legs = [LegFixture::get(LegFixture::HONGKONG_NEWYORK), LegFixture::get(LegFixture::NEWYORK_HAMBURG)]; |
54
|
|
|
|
55
|
|
|
$itinerary = new Itinerary($legs); |
|
|
|
|
56
|
|
|
|
57
|
|
|
$otherLegs = [LegFixture::get(LegFixture::HONGKONG_HAMBURG), LegFixture::get(LegFixture::HAMBURG_ROTTERDAM)]; |
58
|
|
|
|
59
|
|
|
$otherItinerary = new Itinerary($otherLegs); |
|
|
|
|
60
|
|
|
|
61
|
|
|
$this->assertFalse($itinerary->sameValueAs($otherItinerary)); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.