diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-02-21 21:28:49 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-02-21 21:28:49 +0100 |
commit | df428380e288db75b41ace5d6274f44916517f9f (patch) | |
tree | 96055aac98b13e1dd6bd30c3f176117bd2fffa3c /tests | |
parent | 843af14c19f62ca642bcd7af59b8ea413f681c50 (diff) |
Fix whitespace
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Test.php | 205 |
1 files changed, 102 insertions, 103 deletions
diff --git a/tests/Test.php b/tests/Test.php index 0543c1f..2888d81 100644 --- a/tests/Test.php +++ b/tests/Test.php @@ -27,118 +27,118 @@ class Test extends TestCase # root config file_put_contents($contentRoot . '/config/config.toml', <<<EOF - [app] - title = "Flat-File Forms" + [app] + title = "Flat-File Forms" - [email] - host = "localhost" - user = "root" - password = "123456" + [email] + host = "localhost" + user = "root" + password = "123456" - [api] - keys = ["1234"] + [api] + keys = ["1234"] - [api.cors] - origins = ["http://localhost:8081"] - EOF); + [api.cors] + origins = ["http://localhost:8081"] + EOF); # formname config file_put_contents($contentRoot . '/customername/formname/config/config.toml', <<<EOF - [api] - keys = ["asdfghjklö0987654321", "123"] + [api] + keys = ["asdfghjklö0987654321", "123"] - [email] - host = "gmx" - EOF); + [email] + host = "gmx" + EOF); # formname fields file_put_contents($contentRoot . '/customername/formname/fields/_fields.toml', <<<EOF - [field.name] - file = "name.toml" + [field.name] + file = "name.toml" - [field.email] - file = "email.toml" - required = true + [field.email] + file = "email.toml" + required = true - [field.date] - required = true - EOF); + [field.date] + required = true + EOF); file_put_contents($contentRoot . '/customername/formname/fields/email.toml', <<<EOF - type = "email" - name = "email" - placeholder = "E-Mail" + type = "email" + name = "email" + placeholder = "E-Mail" - [attributes] - data-email = "test@example.org" - EOF); + [attributes] + data-email = "test@example.org" + EOF); file_put_contents($contentRoot . '/customername/formname/fields/name.toml', <<<EOF - type = "text" - name = "name" - - [attributes] - data-value = 123 - EOF); - - file_put_contents($contentRoot . '/customername/formname/config/functions.php', ' - <?php - function validate_formname_name($field, $value) - { - if ($value !== \'Harry\') { - $field[\'is_valid\'] = false; + type = "text" + name = "name" + + [attributes] + data-value = 123 + EOF); + + file_put_contents($contentRoot . '/customername/formname/config/functions.php', <<<EOF + <?php + function validate_formname_name(\$field, \$value) + { + if (\$value !== 'Harry') { + \$field['is_valid'] = false; + } + + return \$field; } - - return $field; - } - '); + EOF); # pagedform fields file_put_contents($contentRoot . '/customername/pagedform/fields/_fields.toml', <<<EOF - [page.one.field.name] - file = "name.toml" + [page.one.field.name] + file = "name.toml" - [page.one.field.email] - file = "email.toml" - required = true + [page.one.field.email] + file = "email.toml" + required = true - [page.second] - file = "second.toml" + [page.second] + file = "second.toml" - [page.second.field.date] - required = true - EOF); + [page.second.field.date] + required = true + EOF); file_put_contents($contentRoot . '/customername/pagedform/fields/second.toml', <<<EOF - [field.text] - placeholder = "Text placeholder" + [field.text] + placeholder = "Text placeholder" - [field.text.validation] - pattern = "\\\d+" + [field.text.validation] + pattern = "\\\d+" - [field.manythings] - type = "select" + [field.manythings] + type = "select" - [field.manythings.options] - first = "First level" - second = "Second level" + [field.manythings.options] + first = "First level" + second = "Second level" - [field.multiplethings] - type = "checkbox" - options = ["thing-1", "thing-2", "thing-3"] - EOF); + [field.multiplethings] + type = "checkbox" + options = ["thing-1", "thing-2", "thing-3"] + EOF); file_put_contents($contentRoot . '/customername/pagedform/fields/email.toml', <<<EOF - type = "email" - name = "email" - placeholder = "E-Mail" + type = "email" + name = "email" + placeholder = "E-Mail" - [attributes] - data-email = "test@example.org" - EOF); + [attributes] + data-email = "test@example.org" + EOF); file_put_contents($contentRoot . '/customername/pagedform/fields/name.toml', <<<EOF - type = "text" - name = "name" + type = "text" + name = "name" - [attributes] - data-value = 123 - EOF); + [attributes] + data-value = 123 + EOF); } public function request($method, $path, $options = []): GuzzleHttpResponse @@ -225,14 +225,14 @@ class Test extends TestCase // valid response $response = $this->request('POST', 'customername/pagedform/submit?key=' . $this->apiKey, [ 'form_params' => [ - 'name' => 'NAME', - 'email' => 'EMAIL', - 'date' => 'DATE', - 'text' => '123', - 'manythings' => 'second', - 'multiplethings' => [ - 'thing-1', 'thing-3', - ], + 'name' => 'NAME', + 'email' => 'EMAIL', + 'date' => 'DATE', + 'text' => '123', + 'manythings' => 'second', + 'multiplethings' => [ + 'thing-1', 'thing-3', + ], ], ]); $body = json_decode((string)$response->getBody(), true); @@ -245,9 +245,9 @@ class Test extends TestCase // invalid response $response = $this->request('POST', 'customername/pagedform/submit?key=' . $this->apiKey, [ 'form_params' => [ - 'name' => 'NAME', - 'date' => 'DATE', - 'text' => 'einszweidrei', + 'name' => 'NAME', + 'date' => 'DATE', + 'text' => 'einszweidrei', ], ]); $body = json_decode((string)$response->getBody(), true); @@ -260,8 +260,8 @@ class Test extends TestCase // valid response "one" page $response = $this->request('POST', 'customername/pagedform/validate?page=one&key=' . $this->apiKey, [ 'form_params' => [ - 'name' => 'NAME', - 'email' => 'EMAIL', + 'name' => 'NAME', + 'email' => 'EMAIL', ], ]); $body = json_decode((string)$response->getBody(), true); @@ -275,8 +275,8 @@ class Test extends TestCase // valid response "second" page $response = $this->request('POST', 'customername/pagedform/validate?page=second&key=' . $this->apiKey, [ 'form_params' => [ - 'date' => 'DATE', - 'text' => '123', + 'date' => 'DATE', + 'text' => '123', ], ]); $body = json_decode((string)$response->getBody(), true); @@ -290,9 +290,9 @@ class Test extends TestCase // valid response validation_function $response = $this->request('POST', 'customername/formname/submit?key=' . $this->apiKey, [ 'form_params' => [ - 'name' => 'Harry', - 'email' => 'EMAIL', - 'date' => 'DATE', + 'name' => 'Harry', + 'email' => 'EMAIL', + 'date' => 'DATE', ], ]); $body = json_decode((string)$response->getBody(), true); @@ -305,9 +305,9 @@ class Test extends TestCase // invalid response validation_function $response = $this->request('POST', 'customername/formname/submit?key=' . $this->apiKey, [ 'form_params' => [ - 'name' => 'NAME', - 'email' => 'EMAIL', - 'date' => 'DATE', + 'name' => 'NAME', + 'email' => 'EMAIL', + 'date' => 'DATE', ], ]); $body = json_decode((string)$response->getBody(), true); @@ -318,4 +318,3 @@ class Test extends TestCase $this->assertEquals(true, $body['date']['is_valid']); } } - |