/** * Test for JForm::validate method. * * @return void */ public function testValidate() { $form = new JFormInspector('form1'); $this->assertThat($form->load(JFormDataHelper::$validateDocument), $this->isTrue(), 'Line:' . __LINE__ . ' XML string should load successfully.'); $pass = array('boolean' => 'false', 'optional' => 'Optional', 'required' => 'Supplied', 'group' => array('level1' => 'open')); $fail = array('boolean' => 'comply', 'required' => ''); // Test error conditions. $this->assertThat($form->validate($pass, 'bogus'), $this->isFalse(), 'Line:' . __LINE__ . ' Validating an unknown group should return false.'); $this->assertThat($form->validate($fail), $this->isFalse(), 'Line:' . __LINE__ . ' Any validation failures should return false.'); // Test expected behaviour. $this->assertThat($form->validate($pass), $this->isTrue(), 'Line:' . __LINE__ . ' Validation on this data should pass.'); $this->assertThat($form->validate($pass, 'group'), $this->isTrue(), 'Line:' . __LINE__ . ' Validating an unknown group should return false.'); }