summaryrefslogtreecommitdiff
path: root/tests/HirdTest.php
diff options
context:
space:
mode:
authorAsko Nomm <asko@bien.ee>2022-03-06 22:48:02 +0100
committerAsko Nomm <asko@bien.ee>2022-03-06 22:48:02 +0100
commitf313168d4b53b32b1ee3ce3e2e9ed749848f6985 (patch)
treedc55fed561e6d09ae8a9cd41e4f313d969abd36f /tests/HirdTest.php
parent49a2e23470c291004f2fb203401408225fb61831 (diff)
(MINOR) Implement DateFormatValidator
Diffstat (limited to 'tests/HirdTest.php')
-rw-r--r--tests/HirdTest.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/HirdTest.php b/tests/HirdTest.php
index ef217a1..9b00506 100644
--- a/tests/HirdTest.php
+++ b/tests/HirdTest.php
@@ -69,3 +69,22 @@ test('Validate an incorrect required string', function () {
'null-value is required.',
]);
});
+
+test('Validate a correct date format', function() {
+ $fields = ['date' => '2020-09-17 15:00:12'];
+ $rules = ['date' => 'date-format:Y-m-d H:i:s'];
+ $hird = new Hird($fields, $rules);
+
+ expect($hird->fails())->tobeFalse();
+});
+
+test('Validate an incorrect correct date format', function() {
+ $fields = ['date' => '2020-09-17 15:00'];
+ $rules = ['date' => 'date-format:Y-m-d H:i:s'];
+ $hird = new Hird($fields, $rules);
+ $hird->fails();
+
+ expect($hird->errors())->toBe([
+ 'date does not match the required date format Y-m-d H:i:s.',
+ ]);
+});