public function execute()
 {
     $insurance = $this->insuranceDTO;
     $insuranceFactory = new InsuranceFactory();
     $newInsurance = $insuranceFactory->create($insurance->insuranceId, $insurance->type, new \DateTime($insurance->dateFrom), new \DateTime($insurance->dateTo), $insurance->insurerId);
     $this->car->addInsurance($newInsurance);
     if ($this->documentFile) {
         $this->car->addInsuranceDocument($newInsurance->getId(), $this->documentFile);
     }
     $this->repository->add($this->car);
 }
예제 #2
0
 public function it_should_be_possible_to_remove_InsuranceDocument_from_Insurance()
 {
     $insuranceId = '123-123-123';
     $insurerId = '123-123-123';
     $dateFrom = new \DateTime('23-11-2015');
     $dateTo = new \DateTime('23-11-2016');
     $insuranceFactory = new InsuranceFactory();
     $carInsurance = $insuranceFactory->create($insuranceId, 'AC', $dateFrom, $dateTo, $insurerId);
     $this->addInsurance($carInsurance);
     $this->getInsurances()->shouldContain($carInsurance);
     $carInsuranceDocument = new DocumentFactory();
     $document = $carInsuranceDocument->create(DocumentFactory::INSURANCE_DOCUMENT, 'AC-123', 'AC wrzesień 2015', 'Uzupełnić o nowe dane.', 'path/to/ac_document/1.pdf');
     $this->addInsuranceDocument($carInsurance->getId(), $document);
     $this->getInsuranceDocuments($carInsurance->getId())->shouldContain($document);
     $this->removeInsuranceDocument($carInsurance->getId(), $document->getId())->shouldReturn(0);
     $this->getInsuranceDocuments($carInsurance->getId())->shouldNotContain($document);
 }