protected function createPosts($count) { $author = new Author(); $author->setName('Author'); $this->entityManager()->persist($author); $this->entityManager()->flush(); for ($i = 0; $i < $count; ++$i) { $post = new Post(); $post->setTitle('Title' . $i); $post->setContent('Content' . $i); $post->setAuthor($author); $this->entityManager()->persist($post); } $this->entityManager()->flush(); }
public function testSubmitValidData() { $formData = array('title' => 'test', 'content' => 'testcontent', 'author' => 1); $type = new PostType(); $form = $this->factory->create($type); $object = new Post(); $object->setTitle('test'); $object->setContent('testcontent'); $form->submit($formData); $this->assertTrue($form->isSynchronized()); $this->assertEquals($formData, $form->getData()); $view = $form->createView(); $children = $view->children; foreach (array_keys($formData) as $key) { $this->assertArrayHasKey($key, $children); } }