From 26824441b7d3ac288fab7ef3d551334f4a21c512 Mon Sep 17 00:00:00 2001 From: Fabinatix97 Date: Wed, 5 Feb 2025 11:24:09 +0100 Subject: [PATCH] chore(zms-3235): fixed some schemas --- zmsentities/schema/department.json | 2 +- zmsentities/schema/dereferenced/process.json | 2 +- zmsentities/schema/dereferenced/queue.json | 2 +- zmsentities/schema/dereferenced/session.json | 2 +- zmsentities/schema/queue.json | 2 +- zmsentities/schema/session.json | 6 +++--- zmsentities/src/Zmsentities/Schema/Validator.php | 5 +++++ zmsentities/tests/Zmsentities/DayoffTest.php | 12 ++++++------ zmsentities/tests/Zmsentities/SchemaTest.php | 2 +- zmsentities/tests/Zmsentities/UseraccountTest.php | 4 ++-- zmsentities/tests/Zmsentities/ValidationTest.php | 10 ++++++---- 11 files changed, 28 insertions(+), 21 deletions(-) diff --git a/zmsentities/schema/department.json b/zmsentities/schema/department.json index 32cc274f7..b82af7043 100644 --- a/zmsentities/schema/department.json +++ b/zmsentities/schema/department.json @@ -48,7 +48,7 @@ } ] }, - "additionalProperties": false, + "additionalProperties": true, "properties": { "id": { "type": "number" diff --git a/zmsentities/schema/dereferenced/process.json b/zmsentities/schema/dereferenced/process.json index c51bd3928..1369601ce 100644 --- a/zmsentities/schema/dereferenced/process.json +++ b/zmsentities/schema/dereferenced/process.json @@ -311,7 +311,7 @@ "description": "estimated time in minutes to wait for a call (optimistic value for views with timespan)" }, "withAppointment": { - "type": "boolean", + "type": ["integer", "boolean"], "description": "true if corresponding process has an appointment", "default": false }, diff --git a/zmsentities/schema/dereferenced/queue.json b/zmsentities/schema/dereferenced/queue.json index 223152bce..3e12c9ac0 100644 --- a/zmsentities/schema/dereferenced/queue.json +++ b/zmsentities/schema/dereferenced/queue.json @@ -66,7 +66,7 @@ "description": "estimated time in minutes to wait for a call (optimistic value for views with timespan)" }, "withAppointment": { - "type": "boolean", + "type": ["integer", "boolean"], "description": "true if corresponding process has an appointment", "default": false }, diff --git a/zmsentities/schema/dereferenced/session.json b/zmsentities/schema/dereferenced/session.json index 31e394a1f..8f789d4a8 100644 --- a/zmsentities/schema/dereferenced/session.json +++ b/zmsentities/schema/dereferenced/session.json @@ -105,7 +105,7 @@ "type": "string" }, "clientTelehone": { - "type": "number" + "type": "string" }, "clientAmendment": { "type": "string" diff --git a/zmsentities/schema/queue.json b/zmsentities/schema/queue.json index b42829593..9fc92e333 100644 --- a/zmsentities/schema/queue.json +++ b/zmsentities/schema/queue.json @@ -66,7 +66,7 @@ "description": "estimated time in minutes to wait for a call (optimistic value for views with timespan)" }, "withAppointment": { - "type": "boolean", + "type": ["integer", "boolean"], "description": "true if corresponding process has an appointment", "default": false }, diff --git a/zmsentities/schema/session.json b/zmsentities/schema/session.json index 7dafd24cd..e00e64fb8 100644 --- a/zmsentities/schema/session.json +++ b/zmsentities/schema/session.json @@ -74,17 +74,17 @@ }, "scope": { "type": [ - "number" + "string" ] }, "process": { "type": [ - "number" + "string" ] }, "date": { "type": [ - "number" + "string" ] }, "firstDay": { diff --git a/zmsentities/src/Zmsentities/Schema/Validator.php b/zmsentities/src/Zmsentities/Schema/Validator.php index df93e03f6..b646c1c81 100644 --- a/zmsentities/src/Zmsentities/Schema/Validator.php +++ b/zmsentities/src/Zmsentities/Schema/Validator.php @@ -67,6 +67,11 @@ public function __construct($data, Schema $schemaObject, $locale) // Convert data to JSON object $data = json_decode(json_encode($data)); + // Debugging + // var_dump("Schema:", json_encode($schemaJson, JSON_PRETTY_PRINT)); + // var_dump("*********************************************"); + // var_dump("Data:", json_encode($data, JSON_PRETTY_PRINT)); + // Set max errors and validate $this->validator->setMaxErrors(1000); $this->validator->setStopAtFirstError(false); diff --git a/zmsentities/tests/Zmsentities/DayoffTest.php b/zmsentities/tests/Zmsentities/DayoffTest.php index 6546cddb2..fa1ddd5d1 100644 --- a/zmsentities/tests/Zmsentities/DayoffTest.php +++ b/zmsentities/tests/Zmsentities/DayoffTest.php @@ -103,27 +103,27 @@ protected function getDayOffExampleList() { $list = [ [ - "date" => "1458856800", + "date" => 1458856800, "name" => "Karfreitag" ], [ - "date" => "1459116000", + "date" => 1459116000, "name" => "Ostermontag" ], [ - "date" => "1462053600", + "date" => 1462053600, "name" => "Maifeiertag" ], [ - "date" => "1462399200", + "date" => 1462399200, "name" => "Christi Himmelfahrt" ], [ - "date" => "1463349600", + "date" => 1463349600, "name" => "Pfingstmontag" ], [ - "date" => "1475445600", + "date" => 1475445600, "name" => "Tag der Deutschen Einheit" ] ]; diff --git a/zmsentities/tests/Zmsentities/SchemaTest.php b/zmsentities/tests/Zmsentities/SchemaTest.php index c85f5a6e5..cd32a4109 100644 --- a/zmsentities/tests/Zmsentities/SchemaTest.php +++ b/zmsentities/tests/Zmsentities/SchemaTest.php @@ -73,7 +73,7 @@ protected function getTestEntityMapping() 'contact__country' => 'Germany', 'contact__name' => 'Flughafen Schönefeld, Landebahn', 'email' => 'terminvereinbarung@mitte.berlin.de', - 'id' => '1234', + 'id' => 1234, 'name' => 'Flughafen Schönefeld, Landebahn', 'preferences__notifications__enabled' => true, 'preferences__notifications__identification' => 'terminvereinbarung@mitte.berlin.de', diff --git a/zmsentities/tests/Zmsentities/UseraccountTest.php b/zmsentities/tests/Zmsentities/UseraccountTest.php index 865b6a7fa..bfb487ba6 100644 --- a/zmsentities/tests/Zmsentities/UseraccountTest.php +++ b/zmsentities/tests/Zmsentities/UseraccountTest.php @@ -101,8 +101,8 @@ public function testWithDepartmentListIds() $entity = $this->getExample(); unset($entity->departments); $entity->departments = array( - '141', - '143' + 141, + 143 ); $entity = $entity->withDepartmentList(); $this->assertEquals(2, $entity->getDepartmentList()->count()); diff --git a/zmsentities/tests/Zmsentities/ValidationTest.php b/zmsentities/tests/Zmsentities/ValidationTest.php index 820972f7c..8b9313ce1 100644 --- a/zmsentities/tests/Zmsentities/ValidationTest.php +++ b/zmsentities/tests/Zmsentities/ValidationTest.php @@ -26,6 +26,7 @@ public function testTestValidObject() $this->fail("Expected exception SchemaValidation not thrown"); } catch (\BO\Zmsentities\Exception\SchemaValidation $exception) { foreach ($exception->data as $error) { + $error = $exception->data['/preferences/client/emailFrom']; $this->assertContainsEquals( 'Die E-Mail Adresse muss eine valide E-Mail im Format max@mustermann.de sein', $error['messages'] @@ -44,6 +45,7 @@ public function testTestValidObjectReference() $this->fail("Expected exception SchemaValidation not thrown"); } catch (\BO\Zmsentities\Exception\SchemaValidation $exception) { foreach ($exception->data as $error) { + $error = $exception->data['/contact/email']; $this->assertContainsEquals( 'Die E-Mail Adresse muss eine valide E-Mail im Format max@mustermann.de sein', $error['messages'] @@ -63,10 +65,10 @@ public function testLocale() $this->fail("Expected exception SchemaValidation not thrown"); } catch (\BO\Zmsentities\Exception\SchemaValidation $exception) { $errorList = $exception->data; - // merge conflict, the following two lines might fail?? - $this->assertEquals('changePassword', key($errorList)); - $this->assertArrayHasKey('minLength', $errorList['changePassword']['messages']); - $this->assertArrayHasKey('format', $errorList['changePassword']['messages']); + var_dump($errorList); + $this->assertArrayHasKey('/changePassword', $errorList); + $this->assertArrayHasKey('minLength', $errorList['/changePassword/0']['messages']); + $this->assertArrayHasKey('format', $errorList['/changePassword/0']['messages']); } } }