GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CargoRepositoryDoctrineTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 1
cbo 7
dl 0
loc 54
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A it_returns_a_new_tracking_id() 0 6 1
A it_stores_and_returns_a_cargo() 0 23 1
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\Infrastructure\Persistence\Doctrine;
10
11
use CodelinerTest\CargoBackend\Fixture\LegFixture;
12
use CodelinerTest\CargoBackend\TestCase;
13
use Codeliner\CargoBackend\Model\Cargo;
14
use Codeliner\CargoBackend\Model\Cargo\RouteSpecification;
15
/**
16
 *  CargoRepositoryDoctrineTest
17
 * 
18
 * @author Alexander Miertsch <[email protected]>
19
 */
20
class CargoRepositoryDoctrineTest extends TestCase
21
{
22
    /**
23
     *
24
     * @var Cargo\CargoRepositoryInterface
25
     */
26
    protected $cargoRepository;
27
    
28
    protected function setUp()
29
    {
30
        $this->createEntitySchema('Codeliner\CargoBackend\Model\Cargo\Cargo');
31
        $this->createEntitySchema('Codeliner\CargoBackend\Model\Cargo\Itinerary');
32
        $this->createEntitySchema('Codeliner\CargoBackend\Model\Cargo\RouteSpecification');
33
        
34
        $this->cargoRepository = $this->getTestEntityManager()->getRepository('Codeliner\CargoBackend\Model\Cargo\Cargo');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getTestEntityMana...\\Model\\Cargo\\Cargo') of type object<Doctrine\ORM\EntityRepository> is incompatible with the declared type object<Codeliner\CargoBa...rgoRepositoryInterface> of property $cargoRepository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
35
    }
36
37
    /**
38
     * @test
39
     */
40
    public function it_returns_a_new_tracking_id()
41
    {
42
        $trackingId = $this->cargoRepository->getNextTrackingId();
43
        
44
        $this->assertInstanceOf('Codeliner\CargoBackend\Model\Cargo\TrackingId', $trackingId);
45
    }
46
47
    /**
48
     * @test
49
     */
50
    public function it_stores_and_returns_a_cargo()
51
    {
52
        $trackingId = $this->cargoRepository->getNextTrackingId();
53
        $routeSpecification = new RouteSpecification("Hongkong", "Hamburg");
54
55
        $cargo = new Cargo\Cargo($trackingId, $routeSpecification);
56
57
        $legs = [LegFixture::get(LegFixture::HONGKONG_NEWYORK), LegFixture::get(LegFixture::NEWYORK_HAMBURG)];
58
59
        $itinerary = new Cargo\Itinerary($legs);
0 ignored issues
show
Documentation introduced by
$legs is of type array<integer,object<Cod...el\\Cargo\\Leg>|null"}>, but the function expects a array<integer,object<Cod...ckend\Model\Cargo\Leg>>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60
61
        $cargo->assignToRoute($itinerary);
62
63
        $this->cargoRepository->store($cargo);
64
65
        $this->getTestEntityManager()->clear();
66
        
67
        $checkCargo = $this->cargoRepository->get($trackingId);
68
        
69
        $this->assertTrue($cargo->sameIdentityAs($checkCargo));
70
71
        $this->assertTrue($itinerary->sameValueAs($checkCargo->itinerary()));
72
    }
73
}
74