Exemplo n.º 1
0
 public function testGetters()
 {
     $testData = ['name' => 'petro', 'email' => '*****@*****.**'];
     $data = new FormData(FormData::METHOD_POST, $testData);
     $this->assertEquals(FormData::METHOD_POST, $data->getMethod());
     $this->assertFalse($data->isMethod(FormData::METHOD_GET));
     $this->assertTrue($data->isMethod(FormData::METHOD_POST));
     $this->assertEquals(['name' => 'petro', 'email' => '*****@*****.**'], $data->getData());
     $this->assertEquals('petro', $data->get('name'));
     $this->assertNull($data->get('age'));
     $this->assertTrue($data->has('email'));
     $this->assertFalse($data->has('age'));
 }
Exemplo n.º 2
0
 /**
  * @param FormData $data
  * @return $this
  */
 public function handle(FormData $data)
 {
     $this->cleanValidationFlag();
     $this->isSubmitted = false;
     if ($data->isMethod($this->getMethod()) and $data->has($this->getUid())) {
         $this->isSubmitted = true;
         foreach ($this->getElements() as $element) {
             $element->handle($data);
         }
     }
     return $this;
 }