/** * @covers Acreage::Form::handle_request */ public function test_handle_request_runs_validation_on_fields_with_matching_method_and_is_invalid_if_invalid() { $mock_config = array('validator' => new MockValidator(array('two' => array('invalid')))); $subject = new Form($mock_config); $request = new Request(array('one' => 'one', 'two' => 'two')); $resp = $subject->set_attributes(array('method' => 'GET'))->add_field('one', 'text')->add_field('two', 'text')->handle_request($request); $this->assertFalse($subject->valid()); $this->assertTrue($subject->request_handled); $this->assertSame($subject, $resp); foreach ($subject->fields as $field) { $this->assertTrue($field->validated); if ($field->name == "one") { $this->assertTrue($field->valid); } else { $this->assertFalse($field->valid); } } }