Created
October 19, 2018 03:59
-
-
Save bifidokk/165f872ca008015a30a2e67d5fb0d5d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LoginFormTypeTest extends TypeTestCase | |
| { | |
| protected function setUp() | |
| { | |
| parent::setUp(); | |
| $validator = $this->getMock('\Symfony\Component\Validator\Validator\ValidatorInterface'); | |
| $validator->method('validate')->will($this->returnValue(new ConstraintViolationList())); | |
| $formTypeExtension = new FormTypeValidatorExtension($validator); | |
| $coreExtension = new CoreExtension(); | |
| $this->factory = Forms::createFormFactoryBuilder() | |
| ->addExtensions($this->getExtensions()) | |
| ->addExtension($coreExtension) | |
| ->addTypeExtension($formTypeExtension) | |
| ->getFormFactory(); | |
| } | |
| public function testSubmitValidData() | |
| { | |
| $formData = [ | |
| 'email' => 'bifidokk@gmail.com', | |
| 'plainPassword' => '123456', | |
| ]; | |
| $form = $this->factory->create(LoginFormType::class); | |
| $user = new User(); | |
| $user->setEmail($formData['email']); | |
| $user->setPlainPassword($formData['plainPassword']); | |
| $form->submit($formData); | |
| $this->assertTrue($form->isSynchronized()); | |
| $this->assertTrue($form->isValid()); | |
| $this->assertInstanceOf(User::class, $form->getData()); | |
| $view = $form->createView(); | |
| $children = $view->children; | |
| foreach (\array_keys($formData) as $key) { | |
| $this->assertArrayHasKey($key, $children); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment