diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-03-06 11:45:31 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-03-06 11:45:31 +0100 |
commit | 1334236bb6059b2302a760196ce7885df379e984 (patch) | |
tree | f86e883e6ae9510454307f38be3ffd20aefa6c4c /tests | |
parent | ad83d1dafac62bb28fda004f86129319a5c3e2ca (diff) |
toml to yaml
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Test.php | 180 |
1 files changed, 95 insertions, 85 deletions
diff --git a/tests/Test.php b/tests/Test.php index 2888d81..b111a82 100644 --- a/tests/Test.php +++ b/tests/Test.php @@ -19,64 +19,67 @@ class Test extends TestCase // add content $contentRoot = dirname(__DIR__) . '/content'; - @mkdir($contentRoot . '/config'); - @mkdir($contentRoot . '/customername/formname/config'); - @mkdir($contentRoot . '/customername/formname/fields'); - @mkdir($contentRoot . '/customername/pagedform/config'); - @mkdir($contentRoot . '/customername/pagedform/fields'); + @mkdir($contentRoot . '/config', recursive: true); + @mkdir($contentRoot . '/customername/formname/config', recursive: true); + @mkdir($contentRoot . '/customername/formname/fields', recursive: true); + @mkdir($contentRoot . '/customername/pagedform/config', recursive: true); + @mkdir($contentRoot . '/customername/pagedform/fields', recursive: true); # root config - file_put_contents($contentRoot . '/config/config.toml', <<<EOF - [app] - title = "Flat-File Forms" - - [email] - host = "localhost" - user = "root" - password = "123456" - - [api] - keys = ["1234"] - - [api.cors] - origins = ["http://localhost:8081"] + file_put_contents($contentRoot . '/config/config.yaml', <<<EOF + app: + title: Flat-File Forms + + email: + host: localhost + user: root + password: 123456 + + api: + keys: + - 1234 + cors: + origins: + - https://localhost:8081 EOF); # formname config - file_put_contents($contentRoot . '/customername/formname/config/config.toml', <<<EOF - [api] - keys = ["asdfghjklö0987654321", "123"] - - [email] - host = "gmx" + file_put_contents($contentRoot . '/customername/formname/config/config.yaml', <<<EOF + api: + keys: + - asdfghjklö0987654321 + - 123 + + email: + host: gmx.de EOF); # formname fields - file_put_contents($contentRoot . '/customername/formname/fields/_fields.toml', <<<EOF - [field.name] - file = "name.toml" + file_put_contents($contentRoot . '/customername/formname/fields/_fields.yaml', <<<EOF + name: + file: name.yaml - [field.email] - file = "email.toml" - required = true + email: + file: email.yaml + required: true - [field.date] - required = true + date: + required: true EOF); - file_put_contents($contentRoot . '/customername/formname/fields/email.toml', <<<EOF - type = "email" - name = "email" - placeholder = "E-Mail" + file_put_contents($contentRoot . '/customername/formname/fields/email.yaml', <<<EOF + type: email + name: email + placeholder: E-Mail - [attributes] - data-email = "test@example.org" + attributes: + data-email: test@example.org EOF); - file_put_contents($contentRoot . '/customername/formname/fields/name.toml', <<<EOF - type = "text" - name = "name" + file_put_contents($contentRoot . '/customername/formname/fields/name.yaml', <<<EOF + type: text + name: name - [attributes] - data-value = 123 + attributes: + data-value: 123 EOF); file_put_contents($contentRoot . '/customername/formname/config/functions.php', <<<EOF @@ -89,55 +92,62 @@ class Test extends TestCase return \$field; } + + global \$hooks; + \$hooks->addFilter('validator:formname:field:name', 'validate_formname_name'); EOF); # pagedform fields - file_put_contents($contentRoot . '/customername/pagedform/fields/_fields.toml', <<<EOF - [page.one.field.name] - file = "name.toml" - - [page.one.field.email] - file = "email.toml" - required = true - - [page.second] - file = "second.toml" - - [page.second.field.date] - required = true + file_put_contents($contentRoot . '/customername/pagedform/fields/_fields.yaml', <<<EOF + pages: + one: + fields: + name: + file: name.yaml + email: + file: email.yaml + required: true + + second: + file: second.yaml + fields: + date: + required: true EOF); - file_put_contents($contentRoot . '/customername/pagedform/fields/second.toml', <<<EOF - [field.text] - placeholder = "Text placeholder" - - [field.text.validation] - pattern = "\\\d+" - - [field.manythings] - type = "select" - - [field.manythings.options] - first = "First level" - second = "Second level" - - [field.multiplethings] - type = "checkbox" - options = ["thing-1", "thing-2", "thing-3"] + file_put_contents($contentRoot . '/customername/pagedform/fields/second.yaml', <<<EOF + fields: + text: + placeholder: Text placeholder + validation: + pattern: "\\\d+" + + manythings: + type: select + options: + first: First level + second: Second level + + 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" + file_put_contents($contentRoot . '/customername/pagedform/fields/email.yaml', <<<EOF + type: email + name: email + placeholder: E-Mail - [attributes] - data-email = "test@example.org" + attributes: + data-email: test@example.org EOF); - file_put_contents($contentRoot . '/customername/pagedform/fields/name.toml', <<<EOF - type = "text" - name = "name" + file_put_contents($contentRoot . '/customername/pagedform/fields/name.yaml', <<<EOF + type: text + name: name - [attributes] - data-value = 123 + attributes: + data-value: 123 EOF); } |