Пример #1
0
 /**
  * @dataProvider getValidTestData
  */
 public function testSubmitValidData($formData, $langCode)
 {
     $form = $this->factory->create(LocaleTextType::class, null, ['lang_code' => $langCode]);
     $object = AbstractTest::fromArray(LocaleText::class, $formData);
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($object, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Пример #2
0
 /**
  * @dataProvider getValidTestData
  * @test
  */
 public function shouldSubmitValidData($formData, $langCode, $localeType)
 {
     $form = $this->factory->create($this->getFormType(), null, ['locales' => $langCode, 'locale_type' => $localeType]);
     $result = [];
     foreach ($formData as $data) {
         $result[] = AbstractTest::fromArray(LocaleText::class, $data);
     }
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertInternalType('array', $form->getData());
     $this->assertEquals($result, $form->getData());
     $view = $form->createView();
     $children = $view->children;
     foreach ($formData as $key => $value) {
         $this->assertArrayHasKey($key, $children);
         if ($child = $children[$key]->children) {
             foreach (array_keys($value) as $key) {
                 $this->assertArrayHasKey($key, $child);
             }
         }
     }
 }