Last active
January 4, 2016 13:37
-
-
Save lugecy/b2477755000d15950405 to your computer and use it in GitHub Desktop.
SymfonyでFormTypeのunittestする場合の雛形 (getExtensionsで設定しないと、Validaterが読み込まれず、repeatedフォームを使っているとエラーになる)
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
<?php | |
use Symfony\Component\Form\Test\TypeTestCase; | |
use Symfony\Component\Validator\Validation; | |
use Symfony\Component\Form\Extension\Validator\ValidatorExtension; | |
class PasswordFormType extends TypeTestCase | |
{ | |
protected function getExtensions() | |
{ | |
return [new ValidatorExtension(Validation::createValidator())]; | |
} | |
public function testPasswordLengthValid() | |
{ | |
$formData = [ | |
"userID" => "lugecy", | |
"password" => "passwd", | |
"newPassword" => [ | |
// "first" => "pass", | |
// "second" => "pass", | |
"first" => "p0ssw0rd", | |
"second" => "p0ssw0rd", | |
], | |
]; | |
$type = new App\PasswordFormType(); | |
$form = $this->factory->create($type); | |
$form->submit($formData); | |
// Something Code... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment