Пример #1
0
 /**
  * @dataProvider processDataProvider
  */
 function testProcessData($test_failed, $post, $values)
 {
     $forms = array(Form_Data::createDirect(), Form_Data::createFromConfig());
     $test_failed = Q::normalize($test_failed);
     foreach ($forms as $form) {
         $this->assertTrue(isset($form['name']), 'element "name" not exists.');
         $this->assertTrue(isset($form['price']), 'element "price" not exists.');
         /* @var $form Form_Data */
         $failed = null;
         $ret = $form->validate($post, $failed);
         $this->assertEquals($ret, $form->isValid());
         $this->assertEquals($values, $form->values());
         $this->assertEquals($values, $form->value());
         $this->assertEquals($post, $form->unfilteredValues());
         $this->assertEquals($post, $form->unfilteredValue());
         if (empty($test_failed)) {
             $this->assertTrue($ret);
         } else {
             foreach ($failed as $id => $errors) {
                 $this->assertEquals(false, $form[$id]->isValid());
                 $this->assertEquals($errors, $form[$id]->errorMsg());
             }
             $failed = array_keys($failed);
             $this->assertEquals($test_failed, $failed);
         }
     }
 }
Пример #2
0
 /**
  * @return Form_Data
  */
 static function createFromConfig($id = 'form1')
 {
     $form = new Form_Data($id);
     $form->loadFromConfigFile(dirname(__FILE__) . '/data_form.yaml', false);
     return $form;
 }