1 | <?php |
||
21 | class DataContext implements KernelAwareContext |
||
22 | { |
||
23 | /** |
||
24 | * @var KernelInterface |
||
25 | */ |
||
26 | protected $kernel; |
||
27 | |||
28 | /** |
||
29 | * @param KernelInterface $kernel |
||
30 | */ |
||
31 | public function setKernel(KernelInterface $kernel) |
||
35 | |||
36 | /** |
||
37 | * @BeforeScenario |
||
38 | */ |
||
39 | public function createDatabase() |
||
46 | |||
47 | /** |
||
48 | * @AfterScenario |
||
49 | */ |
||
50 | public function deleteDatabaseIfExist() |
||
58 | |||
59 | /** |
||
60 | * @Then /^new news should be created$/ |
||
61 | */ |
||
62 | public function newNewsShouldBeCreated() |
||
66 | |||
67 | /** |
||
68 | * @Then /^new subscriber should be created$/ |
||
69 | */ |
||
70 | public function newSubscriberShouldBeCreated() |
||
74 | |||
75 | /** |
||
76 | * @Then /^there should be (\d+) news in database$/ |
||
77 | */ |
||
78 | public function thereShouldBeNewsInDatabase($newsCount) |
||
82 | |||
83 | /** |
||
84 | * @Given /^the following news exist in database$/ |
||
85 | */ |
||
86 | public function followingNewsExistInDatabase(TableNode $table) |
||
107 | |||
108 | /** |
||
109 | * @Given /^there are (\d+) news in database$/ |
||
110 | * @Given /^there is (\d+) news in database$/ |
||
111 | */ |
||
112 | public function thereAreNewsInDatabase($newsCount) |
||
131 | |||
132 | /** |
||
133 | * @Given /^there is news with id (\d+) in database$/ |
||
134 | */ |
||
135 | public function thereIsNewsWithIdInDatabase($id) |
||
136 | { |
||
137 | $generator = Factory::create(); |
||
138 | $populator = new Populator($generator, $this->getDoctrine()->getManager()); |
||
139 | |||
140 | $populator->addEntity('FSi\FixturesBundle\Entity\News', 1, array( |
||
141 | 'id' => $id, |
||
142 | 'creatorEmail' => function() use ($generator) { return $generator->email(); }, |
||
143 | 'photoKey' => null |
||
144 | )); |
||
145 | $populator->execute(); |
||
146 | |||
147 | expect(count($this->getEntityRepository('FSi\FixturesBundle\Entity\News')->findAll()))->toBe(1); |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @Then /^there should be news with "([^"]*)" title in database$/ |
||
152 | */ |
||
153 | public function thereShouldBeNewsWithTitleInDatabase($title) |
||
158 | |||
159 | /** |
||
160 | * @Given /^news "([^"]*)" should not exist in database anymore$/ |
||
161 | */ |
||
162 | public function newsShouldNotExistInDatabaseAnymore($title) |
||
168 | |||
169 | |||
170 | /** |
||
171 | * @Given /^there should not be any news in database$/ |
||
172 | */ |
||
173 | public function thereShouldNotBeAnyNewsInDatabase() |
||
177 | |||
178 | /** |
||
179 | * @Given /^there is (\d+) subscriber in database$/ |
||
180 | * @Given /^there are (\d+) subscribers in database$/ |
||
181 | */ |
||
182 | public function thereAreSubscribersInDatabase($count) |
||
194 | |||
195 | /** |
||
196 | * @Given /^there is subscriber with id (\d+) in database$/ |
||
197 | */ |
||
198 | public function thereIsSubscriberWithIdInDatabase($id) |
||
199 | { |
||
200 | $generator = Factory::create(); |
||
201 | $populator = new Populator($generator, $this->getDoctrine()->getManager()); |
||
202 | |||
203 | $populator->addEntity('FSi\FixturesBundle\Entity\Subscriber', 1, array( |
||
204 | 'id' => $id, |
||
205 | 'email' => function() use ($generator) { return $generator->email(); } |
||
206 | )); |
||
207 | $populator->execute(); |
||
208 | |||
209 | expect(count($this->getEntityRepository('FSi\FixturesBundle\Entity\Subscriber')->findAll()))->toBe(1); |
||
210 | } |
||
211 | |||
212 | /** |
||
213 | * @Given /^there should be (\d+) subscribers in database$/ |
||
214 | */ |
||
215 | public function thereShouldBeSubscribersInDatabase($count) |
||
219 | |||
220 | /** |
||
221 | * @Given /^there should not be any subscribers in database$/ |
||
222 | */ |
||
223 | public function thereShouldNotBeAnySubscribersInDatabase() |
||
227 | |||
228 | /** |
||
229 | * @param string $name |
||
230 | * @return \Doctrine\Orm\EntityRepository |
||
231 | */ |
||
232 | protected function getEntityRepository($name) |
||
236 | |||
237 | /** |
||
238 | * @return \Doctrine\Bundle\DoctrineBundle\Registry |
||
239 | */ |
||
240 | protected function getDoctrine() |
||
244 | |||
245 | /** |
||
246 | * @Then /^news should have (\d+) elements in collection "([^"]*)"$/ |
||
247 | */ |
||
248 | public function newsShouldHaveElementsInCollection($expectedCount, $collectionName) |
||
263 | } |
||
264 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.