protected function createAuthors($count) { for ($i = 0; $i < $count; ++$i) { $author = new Author(); $author->setName("Name{$i}"); $this->entityManager()->persist($author); } $this->entityManager()->flush(); }
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('name' => 'test'); $type = new AuthorType(); $form = $this->factory->create($type); $object = new Author(); $object->setName('test'); $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); } }
/** * @return Author */ protected function createAuthor() { $author = new Author(); $author->setName('Author'); $this->entityManager()->persist($author); $this->entityManager()->flush(); return $author; }