public function testSubmitValidData() { $formData = ['priority' => TicketMessage::PRIORITY_HIGH, 'message' => null]; $data = new TicketMessage(); $data->setPriority(TicketMessage::PRIORITY_HIGH); $form = $this->factory->create(method_exists(AbstractType::class, 'getBlockPrefix') ? TicketMessageType::class : new TicketMessageType($this->user), null, ['new_ticket' => true]); // submit the data to the form directly $form->submit($formData); $this->assertTrue($form->isSynchronized()); $formEntity = $form->getData(); $formEntity->setCreatedAt($data->getCreatedAt()); $this->assertEquals($data, $formEntity); $view = $form->createView(); $children = $view->children; foreach (array_keys($formData) as $key) { $this->assertArrayHasKey($key, $children); } }
public function testSubmitValidData() { $formData = array('priority' => TicketMessage::PRIORITY_HIGH, 'message' => null); $userManager = $this->getMock('Hackzilla\\Bundle\\TicketBundle\\User\\UserInterface'); $this->assertTrue($userManager instanceof \Hackzilla\Bundle\TicketBundle\User\UserInterface); $type = new \Hackzilla\Bundle\TicketBundle\Form\Type\TicketMessageType($userManager, true); $data = new \Hackzilla\Bundle\TicketBundle\Entity\TicketMessage(); $data->setPriority(TicketMessage::PRIORITY_HIGH); $form = $this->factory->create($type); // submit the data to the form directly $form->submit($formData); $this->assertTrue($form->isSynchronized()); $formEntity = $form->getData(); $formEntity->setCreatedAt($data->getCreatedAt()); $this->assertEquals($data, $formEntity); $view = $form->createView(); $children = $view->children; foreach (array_keys($formData) as $key) { $this->assertArrayHasKey($key, $children); } }