|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Madkom\RegistryApplication\Domain\CarManagement\Behat; |
|
4
|
|
|
|
|
5
|
|
|
use Behat\Behat\Context\Context; |
|
6
|
|
|
use Behat\Behat\Context\SnippetAcceptingContext; |
|
7
|
|
|
use Behat\Behat\Tester\Exception\PendingException; |
|
8
|
|
|
use Behat\Gherkin\Node\TableNode; |
|
9
|
|
|
use Madkom\RegistryApplication\Application\CarManagement\Command\Insurance\AddInsuranceCommand; |
|
10
|
|
|
use Madkom\RegistryApplication\Application\CarManagement\Command\Insurance\AddInsuranceDocumentCommand; |
|
11
|
|
|
use Madkom\RegistryApplication\Application\CarManagement\DocumentDTO; |
|
12
|
|
|
use Madkom\RegistryApplication\Application\CarManagement\InsuranceDTO; |
|
13
|
|
|
use Madkom\RegistryApplication\Domain\CarManagement\CarExceptions\InvalidDatesException; |
|
14
|
|
|
use Madkom\RegistryApplication\Domain\CarManagement\CarExceptions\NonexistentInsuranceException; |
|
15
|
|
|
use Madkom\RegistryApplication\Domain\CarManagement\Insurances\Exceptions\DuplicatedInsuranceException; |
|
16
|
|
|
|
|
17
|
|
|
class InsuranceManagerContext extends ContextRepositoryInterface implements Context, SnippetAcceptingContext |
|
|
|
|
|
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @Then chciałbym do samochodu :carId dodać ubezpieczenie o następujących danych: |
|
21
|
|
|
*/ |
|
22
|
|
View Code Duplication |
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: |
|
41
|
|
|
* |
|
42
|
|
|
* @throws \Madkom\RegistryApplication\Domain\CarManagement\CarExceptions\InvalidDatesException |
|
43
|
|
|
* @throws \InvalidArgumentException |
|
44
|
|
|
*/ |
|
45
|
|
View Code Duplication |
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
|
|
|
* |
|
71
|
|
|
* @throws \Madkom\RegistryApplication\Domain\CarManagement\CarExceptions\InvalidDatesException |
|
72
|
|
|
* @throws \InvalidArgumentException |
|
73
|
|
|
*/ |
|
74
|
|
View Code Duplication |
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() |
|
101
|
|
|
{ |
|
102
|
|
|
$car = self::$carRepository->find(1); |
|
103
|
|
|
$car->getInsurances(); |
|
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @Then chciałbym do istniejącego ubezpieczenia dodać plik: |
|
108
|
|
|
* @Then chciałbym dodać do istniejącego ubezpieczenia kolejny plik: |
|
109
|
|
|
* @Then chciałbym aby nie było możliwe dodanie pliku do nieistniejącego ubezpieczenia: |
|
110
|
|
|
*/ |
|
111
|
|
|
public function chcialbymDoIstniejacegoUbezpieczeniaDodacPlik(TableNode $table) |
|
112
|
|
|
{ |
|
113
|
|
|
foreach ($table as $item) { |
|
114
|
|
|
$dto = new DocumentDTO($item['fileId'], |
|
115
|
|
|
$item['title'], |
|
116
|
|
|
$item['description'], |
|
117
|
|
|
$item['source'] |
|
118
|
|
|
); |
|
119
|
|
|
|
|
120
|
|
|
$newInsuranceDocument = new AddInsuranceDocumentCommand(self::$carRepository, |
|
121
|
|
|
$item['carId'], |
|
122
|
|
|
$item['insuranceId'], |
|
123
|
|
|
$dto |
|
124
|
|
|
); |
|
125
|
|
|
|
|
126
|
|
|
try { |
|
127
|
|
|
$newInsuranceDocument->execute(); |
|
128
|
|
|
} catch (NonexistentInsuranceException $nonexistent) { |
|
|
|
|
|
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @Then chciałbym aby dla samochodu :carId istniały ubezpieczenia: |
|
135
|
|
|
*/ |
|
136
|
|
|
public function chcialbymAbyDlaSamochoduIstnialyUbezpieczenia($carId, TableNode $table) |
|
137
|
|
|
{ |
|
138
|
|
|
$car = self::$carRepository->find($carId); |
|
139
|
|
|
$insurances = $car->getInsurances(); |
|
|
|
|
|
|
140
|
|
|
|
|
141
|
|
|
$insurancesId = $table->getHash(); |
|
142
|
|
|
|
|
143
|
|
|
foreach ($insurancesId as $key => $value) { |
|
|
|
|
|
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
/** |
|
148
|
|
|
* @Then chciałbym aby dla samochodu :arg1 nie istniały ubezpieczenia o :arg2: |
|
149
|
|
|
*/ |
|
150
|
|
|
public function chcialbymAbyDlaSamochoduNieIstnialyUbezpieczeniaO($arg1, $arg2, TableNode $table) |
|
|
|
|
|
|
151
|
|
|
{ |
|
152
|
|
|
throw new PendingException(); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @Then chciałbym aby w samochodzie :arg1 było ubezpieczenie o id :arg2 |
|
157
|
|
|
*/ |
|
158
|
|
|
public function chcialbymAbyWSamochodzieByloUbezpieczenieOId($arg1, $arg2) |
|
|
|
|
|
|
159
|
|
|
{ |
|
160
|
|
|
throw new PendingException(); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @Then chciałbym aby w samochodzie :arg1 nie było ubezpieczenia o id :arg2 |
|
165
|
|
|
*/ |
|
166
|
|
|
public function chcialbymAbyWSamochodzieNieByloUbezpieczeniaOId($arg1, $arg2) |
|
|
|
|
|
|
167
|
|
|
{ |
|
168
|
|
|
throw new PendingException(); |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* @Then chciałbym aby nie było możliwe dodanie kolejnego pliku o id :arg1 |
|
173
|
|
|
*/ |
|
174
|
|
|
public function chcialbymAbyNieByloMozliweDodanieKolejnegoPlikuOId($arg1) |
|
|
|
|
|
|
175
|
|
|
{ |
|
176
|
|
|
throw new PendingException(); |
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
/** |
|
180
|
|
|
* @Then chciałbym aby nie była możliwa podmiana istniejącego pliku :arg1 |
|
181
|
|
|
*/ |
|
182
|
|
|
public function chcialbymAbyNieBylaMozliwaPodmianaIstniejacegoPliku($arg1) |
|
|
|
|
|
|
183
|
|
|
{ |
|
184
|
|
|
throw new PendingException(); |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* @Then chciałbym usunąć plik :arg1 |
|
189
|
|
|
*/ |
|
190
|
|
|
public function chcialbymUsunacPlik($arg1) |
|
|
|
|
|
|
191
|
|
|
{ |
|
192
|
|
|
throw new PendingException(); |
|
193
|
|
|
} |
|
194
|
|
|
|
|
195
|
|
|
/** |
|
196
|
|
|
* @Then chciałbym aby nie było możliwe pobranie pliku :arg1 |
|
197
|
|
|
*/ |
|
198
|
|
|
public function chcialbymAbyNieByloMozliwePobraniePliku($arg1) |
|
|
|
|
|
|
199
|
|
|
{ |
|
200
|
|
|
throw new PendingException(); |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
/** |
|
204
|
|
|
* @Then chciałbym aby nie było możliwe usunięcie pliku :arg1 |
|
205
|
|
|
*/ |
|
206
|
|
|
public function chcialbymAbyNieByloMozliweUsunieciePliku($arg1) |
|
|
|
|
|
|
207
|
|
|
{ |
|
208
|
|
|
throw new PendingException(); |
|
209
|
|
|
} |
|
210
|
|
|
} |
|
211
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.