diff options
-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']); } } |