/** * @Given there is :nb dummy objects with dummyDate */ public function thereIsDummyObjectsWithDummyDate($nb) { for ($i = 1; $i <= $nb; $i++) { $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = new Dummy(); $dummy->setName('Dummy #' . $i); $dummy->setAlias('Alias #' . ($nb - $i)); $dummy->setDummyDate($date); $this->manager->persist($dummy); } $this->manager->flush(); }
/** * @Given there is :nb dummy objects with dummyDate and relatedDummy */ public function thereIsDummyObjectsWithDummyDateAndRelatedDummy($nb) { for ($i = 1; $i <= $nb; ++$i) { $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $relatedDummy = new RelatedDummy(); $relatedDummy->setName('RelatedDummy #' . $i); $relatedDummy->setDummyDate($date); $dummy = new Dummy(); $dummy->setName('Dummy #' . $i); $dummy->setAlias('Alias #' . ($nb - $i)); $dummy->setRelatedDummy($relatedDummy); // Last Dummy has a null date if ($nb !== $i) { $dummy->setDummyDate($date); } $this->manager->persist($relatedDummy); $this->manager->persist($dummy); } $this->manager->flush(); }
/** * @Given there is :nb dummy objects with dummyDate */ public function thereIsDummyObjectsWithDummyDate($nb) { $descriptions = ['Smart dummy.', 'Not so smart dummy.']; for ($i = 1; $i <= $nb; ++$i) { $date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC')); $dummy = new Dummy(); $dummy->setName('Dummy #' . $i); $dummy->setAlias('Alias #' . ($nb - $i)); $dummy->setDescription($i % 2 ? $descriptions[0] : $descriptions[1]); // Last Dummy has a null date if ($nb !== $i) { $dummy->setDummyDate($date); } $this->manager->persist($dummy); } $this->manager->flush(); }