Permalink
Browse files

Make sure form setup actually worked

  • Loading branch information...
flack committed Feb 8, 2019
1 parent 16bd91e commit 416f89fc252c28f8b4359e9fbe64d77c83a2ff78
Showing with 6 additions and 1 deletion.
  1. +6 −1 test/utilities/testcase.php
@@ -11,6 +11,7 @@
use midcom\datamanager\renderer;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Base class for unittests, provides some helper methods
@@ -207,14 +208,18 @@ public function submit_dm_form($controller_key, array $formdata, $component, arr
{
$this->reset_server_vars();
$data = $this->run_handler($component, $args);
if ( array_key_exists('__openpsa_testcase_response', $data)
&& $data['__openpsa_testcase_response'] instanceof RedirectResponse) {
$this->fail('Handler relocated to ' . $data['__openpsa_testcase_response']->getTargetUrl() . ' during form setup');
}
$this->set_dm_formdata($data[$controller_key], $formdata, $button);
try {
$data = $this->run_handler($component, $args);
if (array_key_exists($controller_key, $data)) {
$this->assertEquals([], $data[$controller_key]->get_errors(), 'Form validation failed');
}
$this->assertInstanceOf(midcom_response_relocate::class, $data['__openpsa_testcase_response'], 'Form did not relocate');
$this->assertInstanceOf(RedirectResponse::class, $data['__openpsa_testcase_response'], 'Form did not relocate');
return $data['__openpsa_testcase_response']->getTargetUrl();
} catch (openpsa_test_relocate $e) {
$url = $e->getMessage();

0 comments on commit 416f89f

Please sign in to comment.