コード例 #1
0
ファイル: FormTest.php プロジェクト: sevikerr/form
 public function testHandleRequest()
 {
     $form = new Form();
     $form->addElement((new Input())->setName('email'));
     $form->addElement((new TextArea())->setName('description'));
     $form->setMethod('post');
     $form->handle(new FormData('post', [$form->getUid() => 1, 'email' => '*****@*****.**', 'description' => 'some description text']));
     $this->assertTrue($form->isSubmitted());
     $this->assertEquals('*****@*****.**', $form->getElement('email')->getValue());
     $this->assertEquals('some description text', $form->getElement('description')->getValue());
     $form->handle(new FormData('post', [$form->getUid() => 1, 'email' => '*****@*****.**']));
     $this->assertTrue($form->isSubmitted());
     $this->assertEquals('*****@*****.**', $form->getElement('email')->getValue());
     $this->assertNull($form->getElement('description')->getValue());
     $form->handle(new FormData('post', [$form->getUid() => '1']));
     $this->assertTrue($form->isSubmitted());
     $this->assertNull($form->getElement('email')->getValue());
     $this->assertNull($form->getElement('description')->getValue());
     $form->handle(new FormData('post', []));
     $this->assertFalse($form->isSubmitted());
 }