| @@ 8-32 (lines=25) @@ | ||
| 5 | use Loevgaard\DandomainAltapayBundle\Form\SiteSettingType; |
|
| 6 | use Symfony\Component\Form\Test\TypeTestCase; |
|
| 7 | ||
| 8 | class SiteSettingTypeTest extends TypeTestCase |
|
| 9 | { |
|
| 10 | public function testSubmitValidData() |
|
| 11 | { |
|
| 12 | $formData = [ |
|
| 13 | 'siteId' => '26', |
|
| 14 | 'setting' => 'setting', |
|
| 15 | 'val' => 'val', |
|
| 16 | ]; |
|
| 17 | ||
| 18 | $form = $this->factory->create(SiteSettingType::class); |
|
| 19 | ||
| 20 | // submit the data to the form directly |
|
| 21 | $form->submit($formData); |
|
| 22 | ||
| 23 | $this->assertTrue($form->isSynchronized()); |
|
| 24 | ||
| 25 | $view = $form->createView(); |
|
| 26 | $children = $view->children; |
|
| 27 | ||
| 28 | foreach (array_keys($formData) as $key) { |
|
| 29 | $this->assertArrayHasKey($key, $children); |
|
| 30 | } |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| @@ 8-31 (lines=24) @@ | ||
| 5 | use Loevgaard\DandomainAltapayBundle\Form\TestType; |
|
| 6 | use Symfony\Component\Form\Test\TypeTestCase; |
|
| 7 | ||
| 8 | class TestTypeTest extends TypeTestCase |
|
| 9 | { |
|
| 10 | public function testSubmitValidData() |
|
| 11 | { |
|
| 12 | $formData = [ |
|
| 13 | 'APIkey' => 'key', |
|
| 14 | 'APIMerchant' => 'merchant', |
|
| 15 | ]; |
|
| 16 | ||
| 17 | $form = $this->factory->create(TestType::class); |
|
| 18 | ||
| 19 | // submit the data to the form directly |
|
| 20 | $form->submit($formData); |
|
| 21 | ||
| 22 | $this->assertTrue($form->isSynchronized()); |
|
| 23 | ||
| 24 | $view = $form->createView(); |
|
| 25 | $children = $view->children; |
|
| 26 | ||
| 27 | foreach (array_keys($formData) as $key) { |
|
| 28 | $this->assertArrayHasKey($key, $children); |
|
| 29 | } |
|
| 30 | } |
|
| 31 | } |
|
| 32 | ||