|
@@ 22-37 (lines=16) @@
|
| 19 |
|
/** |
| 20 |
|
* @Then chciałbym do samochodu :carId dodać ubezpieczenie o następujących danych: |
| 21 |
|
*/ |
| 22 |
|
public function chcialbymDoSamochoduDodacUbezpieczenieONastepujacychDanych($carId, TableNode $table) |
| 23 |
|
{ |
| 24 |
|
$insurance = $table->getHash(); |
| 25 |
|
|
| 26 |
|
foreach ($insurance as $item) { |
| 27 |
|
$dto = new InsuranceDTO($item['id'], |
| 28 |
|
$item['type'], |
| 29 |
|
$item['dateFrom'], |
| 30 |
|
$item['dateTo'], |
| 31 |
|
$item['insurerId'] |
| 32 |
|
); |
| 33 |
|
|
| 34 |
|
$newInsurance = AddInsuranceCommand::add(self::$carRepository, $carId, $dto); |
| 35 |
|
$newInsurance->execute(); |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
/** |
| 40 |
|
* @Then nie można dodać ubezpieczenia do samochodu :carId, gdy różnica między dateFrom i dateTo jest inna niż jeden rok: |
|
@@ 45-67 (lines=23) @@
|
| 42 |
|
* @throws \Madkom\RegistryApplication\Domain\CarManagement\CarExceptions\InvalidDatesException |
| 43 |
|
* @throws \InvalidArgumentException |
| 44 |
|
*/ |
| 45 |
|
public function nieMoznaDodacUbezpieczeniaDoSamochoduGdyRoznicaMiedzyDateFromIDateToJestInnaNizJedenRok($carId, TableNode $table) |
| 46 |
|
{ |
| 47 |
|
$insurance = $table->getHash(); |
| 48 |
|
|
| 49 |
|
foreach ($insurance as $item) { |
| 50 |
|
$dto = new InsuranceDTO($item['id'], |
| 51 |
|
$item['type'], |
| 52 |
|
$item['dateFrom'], |
| 53 |
|
$item['dateTo'], |
| 54 |
|
$item['insurerId'] |
| 55 |
|
); |
| 56 |
|
|
| 57 |
|
$newInsurance = AddInsuranceCommand::add(self::$carRepository, $carId, $dto); |
| 58 |
|
|
| 59 |
|
try { |
| 60 |
|
$newInsurance->execute(); |
| 61 |
|
throw new \InvalidArgumentException('W tym teście spodziewano się wyjątku InvalidDatesException, ale go nie otrzymano'); |
| 62 |
|
} catch (InvalidDatesException $datesException) { |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
/** |
| 68 |
|
* @Then nie można dodać kolejnego ubezpieczenia do samochodu :carId, którego data rozpoczęcia będzie wcześniej niż data końca poprzedniego: |
| 69 |
|
* @Then nie można dodać kolejnego ubezpieczenia do samochodu :carId, którego data rozpoczęcia będzie później niż data końca poprzedniego: |
| 70 |
|
* |
|
@@ 74-97 (lines=24) @@
|
| 71 |
|
* @throws \Madkom\RegistryApplication\Domain\CarManagement\CarExceptions\InvalidDatesException |
| 72 |
|
* @throws \InvalidArgumentException |
| 73 |
|
*/ |
| 74 |
|
public function nieMoznaDodacKolejnegoUbezpieczeniaDoSamochoduKtoregoDataRozpoczeciaBedzieWczesniejNizDataKoncaPoprzedniego($carId, TableNode $table) |
| 75 |
|
{ |
| 76 |
|
$insurance = $table->getHash(); |
| 77 |
|
|
| 78 |
|
foreach ($insurance as $item) { |
| 79 |
|
$dto = new InsuranceDTO($item['id'], |
| 80 |
|
$item['type'], |
| 81 |
|
$item['dateFrom'], |
| 82 |
|
$item['dateTo'], |
| 83 |
|
$item['insurerId'] |
| 84 |
|
); |
| 85 |
|
|
| 86 |
|
$newInsurance = AddInsuranceCommand::add(self::$carRepository, $carId, $dto); |
| 87 |
|
|
| 88 |
|
try { |
| 89 |
|
$newInsurance->execute(); |
| 90 |
|
throw new \InvalidArgumentException('W tym teście spodziewano się wyjątku InvalidDatesException, ale go nie otrzymano'); |
| 91 |
|
} catch (InvalidDatesException $datesException) { |
| 92 |
|
} catch (DuplicatedInsuranceException $duplicatesException) { |
| 93 |
|
} |
| 94 |
|
} |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
/** |
| 98 |
|
* @Given w repozytorium dodane ubezpieczenia |
| 99 |
|
*/ |
| 100 |
|
public function wRepozytoriumDodaneUbezpieczenia() |