diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-01-06 00:56:41 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-01-10 11:29:13 +0100 |
commit | 0b0af86264107a9c95ff37a1b3fdc845aa7a27b2 (patch) | |
tree | 0ec54ad83d4d6908e60fa3d5189887676ae49df8 | |
parent | d6c5c7735e3207ead7759375e444bc6b72045e49 (diff) |
Test single page validation
-rw-r--r-- | tests/Test.php | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/Test.php b/tests/Test.php index abb4749..37e5f65 100644 --- a/tests/Test.php +++ b/tests/Test.php @@ -38,7 +38,7 @@ class Test extends TestCase keys = ["1234"] [api.cors] - origins = [] + origins = ["http://localhost:8081"] EOF); # formname config @@ -209,6 +209,7 @@ class Test extends TestCase public function testValidation() { + // valid response $response = $this->request('POST', 'customername/pagedform/submit?key=' . $this->apiKey, [ 'form_params' => [ 'name' => 'NAME', @@ -228,6 +229,7 @@ class Test extends TestCase $this->assertEquals(true, $body['second']['date']['is_valid']); $this->assertEquals(true, $body['second']['text']['is_valid']); + // invalid response $response = $this->request('POST', 'customername/pagedform/submit?key=' . $this->apiKey, [ 'form_params' => [ 'name' => 'NAME', @@ -241,6 +243,36 @@ class Test extends TestCase $this->assertEquals(false, $body['one']['email']['is_valid']); $this->assertEquals(true, $body['second']['date']['is_valid']); $this->assertEquals(false, $body['second']['text']['is_valid']); + + // valid response "one" page + $response = $this->request('POST', 'customername/pagedform/validate?page=one&key=' . $this->apiKey, [ + 'form_params' => [ + 'name' => 'NAME', + 'email' => 'EMAIL', + ], + ]); + $body = json_decode((string)$response->getBody(), true); + $this->assertArrayNotHasKey('error', $body); + $body = $body['data']; + $this->assertArrayNotHasKey('one', $body); + $this->assertArrayNotHasKey('second', $body); + $this->assertEquals(true, $body['name']['is_valid']); + $this->assertEquals(true, $body['email']['is_valid']); + + // valid response "second" page + $response = $this->request('POST', 'customername/pagedform/validate?page=second&key=' . $this->apiKey, [ + 'form_params' => [ + 'date' => 'DATE', + 'text' => '123', + ], + ]); + $body = json_decode((string)$response->getBody(), true); + $this->assertArrayNotHasKey('error', $body); + $body = $body['data']; + $this->assertArrayNotHasKey('one', $body); + $this->assertArrayNotHasKey('second', $body); + $this->assertEquals(true, $body['date']['is_valid']); + $this->assertEquals(true, $body['text']['is_valid']); } } |