/** * Construct * * @param TrackingId $aTrackingId * @param RouteSpecification $aRouteSpecification */ public function __construct(TrackingId $aTrackingId, RouteSpecification $aRouteSpecification) { //Unfortunately, doctrine does not work with ValueObjects as identifier, //so we have to use the string representation internally //@see http://www.doctrine-project.org/jira/browse/DDC-2984 $this->trackingIdString = $aTrackingId->toString(); //Construct is only called when the Cargo is initially created. //Doctrine do not call __construct when it recreates a persisted entity. //Therefor we can assign the origin here. //It will be always the same for that specific Cargo even if the RouteSpecification changes. $this->origin = $aRouteSpecification->origin(); $this->routeSpecification = $aRouteSpecification; }
/** * {@inheritDoc} */ public function get(TrackingId $trackingId) { return $this->find($trackingId->toString()); }
/** * @test */ public function it_returns_string_representation_of_uuid() { $uuid = Uuid::uuid4(); $trackingId = new TrackingId($uuid); $this->assertEquals($uuid->toString(), $trackingId->toString()); }