public function load(ObjectManager $manager) { $districts = array('Центр', 'Казбет', 'Днепровский', 'Хим. посолек', 'ЮЗР', 'Громова', 'Луна', 'Сосновка', 'Дахновка', 'Школьная'); for ($i = 0; $i < count($districts); $i++) { $district = new District(); $district->setTitle($districts[$i]); $manager->persist($district); } $manager->flush(); }
public function testSubmitValidData() { $formData = array('title' => 'Test title'); $form = $this->factory->create(DistrictType::class); $object = new District(); $object->setTitle('Test title'); $form->submit($formData); $this->assertTrue($form->isSynchronized()); $this->assertEquals($object, $form->getData()); $view = $form->createView(); $children = $view->children; foreach (array_keys($formData) as $key) { $this->assertArrayHasKey($key, $children); } }
private function createDeleteForm(District $district) { return $this->createFormBuilder()->setAction($this->generateUrl('admin_district_delete', array('slug' => $district->getSlug())))->setMethod('DELETE')->getForm(); }