diff --git a/.htaccess b/.htaccess index 8826a3601..8f2e4166c 100644 --- a/.htaccess +++ b/.htaccess @@ -39,6 +39,14 @@ RewriteRule ^terminvereinbarung/calldisplay(.*) /var/www/html/zmscalldisplay/pub RewriteRule ^terminvereinbarung/calldisplay/+_(.*) /var/www/html/zmscalldisplay/public/_$1 [QSA] +# zmscitizenapi +SetEnvIf Request_URI ^/zmscitizenapi ZMS_MODULE_BASEPATH=/terminvereinbarung/api/citizen +RewriteCond %{REQUEST_URI} !^/terminvereinbarung/api/citizen/+(_|doc) +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^terminvereinbarung/api/citizen(.*) /var/www/html/zmscitizenapi/public/index.php?$1 [QSA] +RewriteRule ^terminvereinbarung/api/citizen/+(doc|_)(.*) /var/www/html/zmscitizenapi/public/$1$2 [QSA] + + # zmsstatistic SetEnvIf Request_URI ^/zmsstatistic ZMS_MODULE_BASEPATH=/terminvereinbarung/statistic RewriteCond %{REQUEST_URI} !^/terminvereinbarung/[^/]+/+_ diff --git a/zmscitizenapi/src/Zmscitizenapi/AppointmentUpdate.php b/zmscitizenapi/src/Zmscitizenapi/AppointmentUpdate.php index 09a6fe3b0..3fb793ee1 100644 --- a/zmscitizenapi/src/Zmscitizenapi/AppointmentUpdate.php +++ b/zmscitizenapi/src/Zmscitizenapi/AppointmentUpdate.php @@ -3,14 +3,60 @@ namespace BO\Zmscitizenapi; use BO\Zmscitizenapi\BaseController; -use BO\Slim\Render; +use BO\Zmscitizenapi\Services\ZmsApiFacadeService; +use BO\Zmscitizenapi\Services\ValidationService; +use BO\Zmscitizenapi\Helper\UtilityHelper; +use BO\Zmscitizenapi\Services\ExceptionService; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; class AppointmentUpdate extends BaseController { public function readResponse(RequestInterface $request, ResponseInterface $response, array $args) { - return Render::withJson($response, []); + $request = $request instanceof ServerRequestInterface ? $request : null; + + $body = $request->getParsedBody(); + $processId = $body['processId'] ?? null; + $authKey = $body['authKey'] ?? null; + $familyName = $body['familyName'] ?? null; + $email = $body['email'] ?? null; + $telephone = $body['telephone'] ?? null; + $customTextfield = $body['customTextfield'] ?? null; + + $errors = ValidationService::validateUpdateAppointmentInputs($processId, $authKey, $familyName, $email, $telephone, $customTextfield); + if (!empty($errors['errors'])) { + return $this->createJsonResponse($response, $errors, 400); + } + + try { + + $reservedProcess = ZmsApiFacadeService::getProcessById($processId, $authKey); + if (!empty($reservedProcess['errors'])) { + return $this->createJsonResponse($response, $reservedProcess, 404); + } + + $reservedProcess['clients'][0]['familyName'] = $familyName; + $reservedProcess['clients'][0]['email'] = $email; + $reservedProcess['clients'][0]['telephone'] = $telephone; + $reservedProcess['customTextfield'] = $customTextfield; + + $updatedProcess = ZmsApiFacadeService::updateClientData($reservedProcess); + + if (isset($updatedProcess['exception']) && $updatedProcess['exception'] === 'tooManyAppointmentsWithSameMail') { + return $this->createJsonResponse($response, ExceptionService::tooManyAppointmentsWithSameMail(), 406); + } + + $thinnedProcessData = UtilityHelper::getThinnedProcessData($updatedProcess); + return $this->createJsonResponse($response, $thinnedProcessData, 200); + + } catch (\Exception $e) { + return [ + 'errorCode' => 'unexpectedError', + 'errorMessage' => 'Unexpected error: ' . $e->getMessage(), + 'status' => 500, + ]; + } } -} +} \ No newline at end of file diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/ExceptionService.php b/zmscitizenapi/src/Zmscitizenapi/Services/ExceptionService.php index dec1e7a9a..e5efadd5b 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/ExceptionService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/ExceptionService.php @@ -5,7 +5,7 @@ class ExceptionService { - public static function exceptionNoAppointmentsAtLocation(){ + public static function noAppointmentsAtLocation(){ $errors[] = [ 'errorCode' => 'noAppointmentForThisOffice', @@ -17,4 +17,27 @@ public static function exceptionNoAppointmentsAtLocation(){ } + public static function appointmentNotFound(){ + + $errors[] = [ + 'errorCode' => 'appointmentNotFound', + 'errorMessage' => 'Termin wurde nicht gefunden.', + 'status' => 404, + ]; + + return ['errors' => $errors, 'status' => 404]; + + } + + public static function tooManyAppointmentsWithSameMail(){ + $errors[] = [ + 'errorCode' => 'tooManyAppointmentsWithSameMail', + 'errorMessage' => 'Zu viele Termine mit gleicher E-Mail- Adresse.', + 'status' => 406, + ]; + + return ['errors' => $errors, 'status' => 406]; + + } + } \ No newline at end of file diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php b/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php index 91b6c01fc..21da3485a 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php @@ -83,28 +83,28 @@ public static function validateGetAvailableAppointments($date, $officeId, $servi 'errorMessage' => 'date is required and must be a valid date.', ]; } - + if (!$officeId || !is_numeric($officeId)) { $errors[] = [ 'status' => 400, 'errorMessage' => 'officeId should be a 32-bit integer.', ]; } - + if (empty($serviceIds[0]) || !preg_match('/^\d+(,\d+)*$/', implode(',', $serviceIds))) { $errors[] = [ 'status' => 400, 'errorMessage' => 'serviceId should be a comma-separated string of integers.', ]; } - + if (empty($serviceCounts[0]) || !preg_match('/^\d+(,\d+)*$/', implode(',', $serviceCounts))) { $errors[] = [ 'status' => 400, 'errorMessage' => 'serviceCount should be a comma-separated string of integers.', ]; } - + return ['errors' => $errors, 'status' => 400]; } public static function validatePostAppointmentReserve($officeId, $serviceIds, $serviceCounts, $captchaSolution, $timestamp) @@ -184,7 +184,8 @@ public static function validateGetScopeByIds($scopeIds) return ['errors' => $errors, 'status' => 400]; } - public static function validateGetServicesByOfficeIds($officeIds){ + public static function validateGetServicesByOfficeIds($officeIds) + { $errors = []; if (empty($officeIds) || $officeIds == ['']) { @@ -234,7 +235,7 @@ public static function validateGetProcessNotFound($process) if (!$process) { $errors[] = [ 'errorCode' => 'appointmentNotAvailable', - 'errorMessage' => 'Der von Ihnen gewählte Termin ist leider nicht mehr verfügbar.', + 'errorMessage' => 'Der von Ihnen gewählte Termin ist leider nicht mehr verfügbar.', 'status' => 404, ]; } @@ -248,7 +249,7 @@ public static function validateScopesNotFound($scopes) if (empty($scopes)) { $errors[] = [ 'errorCode' => 'scopesNotFound', - 'errorMessage' => 'Scope(s) not found.', + 'errorMessage' => 'Scope(s) not found.', 'status' => 404, ]; } @@ -262,7 +263,7 @@ public static function validateServicesNotFound($services) if (empty($services)) { $errors[] = [ 'errorCode' => 'servicesNotFound', - 'errorMessage' => 'Service(s) not found for the provided officeId(s).', + 'errorMessage' => 'Service(s) not found for the provided officeId(s).', 'status' => 404, ]; } @@ -276,7 +277,7 @@ public static function validateOfficesNotFound($offices) if (empty($offices)) { $errors[] = [ 'errorCode' => 'officesNotFound', - 'errorMessage' => 'Office(s) not found for the provided serviceId(s).', + 'errorMessage' => 'Office(s) not found for the provided serviceId(s).', 'status' => 404, ]; } @@ -298,7 +299,8 @@ public static function validateAppointmentDaysNotFound($formattedDays) return ['errors' => $errors, 'status' => 404]; } - public static function validateNoAppointmentsAtLocation(){ + public static function validateNoAppointmentsAtLocation() + { $errors[] = [ 'errorCode' => 'noAppointmentForThisScope', @@ -310,4 +312,59 @@ public static function validateNoAppointmentsAtLocation(){ } -} \ No newline at end of file + public static function validateUpdateAppointmentInputs($processId, $authKey, $familyName, $email, $telephone, $customTextfield) + { + $errors = []; + + if (!$processId || !is_numeric($processId) || intval($processId) <= 0) { + $errors[] = [ + 'status' => 400, + 'errorMessage' => 'processId should be a positive 32-bit integer.', + ]; + } + + if (!$authKey || !is_string($authKey)) { + $errors[] = [ + 'status' => 400, + 'errorMessage' => 'authKey should be a non-empty string.', + ]; + } + + if (!$familyName || !is_string($familyName)) { + $errors[] = [ + 'status' => 400, + 'errorMessage' => 'familyName should be a non-empty string.', + ]; + } + + if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) { + $errors[] = [ + 'status' => 400, + 'errorMessage' => 'email should be a valid email address.', + ]; + } + + if ($telephone !== null && !$telephone || !preg_match('/^\d{7,15}$/', $telephone)) { + $errors[] = [ + 'status' => 400, + 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.', + ]; + } + + if ($customTextfield !== null && !is_string($customTextfield)) { + $errors[] = [ + 'status' => 400, + 'errorMessage' => 'customTextfield should be a string.', + ]; + } + + if (!empty($errors)) { + return ['errors' => $errors, 'status' => 400]; + } + + return ['status' => 200, 'message' => 'Valid input for updating appointment.']; + } + + +} + diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiClientService.php b/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiClientService.php index 4f5d0519e..aa05bfa53 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiClientService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiClientService.php @@ -44,7 +44,8 @@ public static function getServices() } - public static function getRequestRelationList(){ + public static function getRequestRelationList() + { $sources = \App::$http->readGetResult('/source/' . \App::$source_name . '/', [ 'resolveReferences' => 2, @@ -89,15 +90,14 @@ public static function getFreeTimeslots($providers, $requests, $firstDay, $lastD } $psr7Response = $result->getResponse(); - $responseBody = (string) $psr7Response->getBody(); - + return $result; } public static function reserveTimeslot($appointmentProcess, $serviceIds, $serviceCounts) { $requests = []; - + foreach ($serviceIds as $index => $serviceId) { $count = intval($serviceCounts[$index]); for ($i = 0; $i < $count; $i++) { @@ -109,32 +109,61 @@ public static function reserveTimeslot($appointmentProcess, $serviceIds, $servic } $processEntity = new ProcessEntity(); - + $processEntity->appointments = $appointmentProcess['appointments'] ?? []; $processEntity->authKey = $appointmentProcess['authKey'] ?? null; $processEntity->clients = $appointmentProcess['clients'] ?? []; - + $processEntity->scope = $appointmentProcess['scope'] ?? null; $processEntity->requests = $requests; $processEntity->lastChange = $appointmentProcess['lastChange'] ?? time(); - + $processEntity->createIP = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; $processEntity->createTimestamp = time(); - + if (isset($appointmentProcess['queue'])) { $processEntity->queue = $appointmentProcess['queue']; } - + $result = \App::$http->readPostResult('/process/status/reserved/', $processEntity); - + return $result->getEntity(); } - public function submitClientData($process) + public static function submitClientData($process) { - $url = "/process/{$process['id']}/{$process['authKey']}/"; - return \App::$http->readPostResult($url, $process)->getEntity(); + $processEntity = new ProcessEntity(); + $processEntity->id = $process['data']['processId'] ?? null; + $processEntity->authKey = $process['data']['authKey'] ?? null; + $processEntity->appointments = $process['appointments'] ?? []; + $processEntity->clients = $process['clients'] ?? []; + $processEntity->scope = $process['data']['scope'] ?? null; + $processEntity->customTextfield = $process['customTextfield'] ?? null; + $processEntity->lastChange = $process['lastChange'] ?? time(); + + if (isset($process['queue'])) { + $processEntity->queue = $process['queue']; + } + + $processEntity->createIP = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1'; + $processEntity->createTimestamp = time(); + + $url = "/process/{$processEntity->id}/{$processEntity->authKey}/"; + + try { + $result = \App::$http->readPostResult($url, $processEntity); + return $result->getEntity(); + } catch (\Exception $e) { + $exceptionName = json_decode(json_encode($e), true)['template'] ?? null; + if ($exceptionName === 'BO\\Zmsapi\\Exception\\Process\\MoreThanAllowedAppointmentsPerMail') { + $exception = [ + 'exception' => 'tooManyAppointmentsWithSameMail' + ]; + return $exception; + } + } + } public function preconfirmProcess($process) diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php b/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php index 4f23c0597..e97ca5f33 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php @@ -11,7 +11,7 @@ public static function getOffices() { $scopeList = ZmsApiClientService::getScopes() ?? []; $providerProjectionList = []; - + foreach (ZmsApiClientService::getOffices() as $provider) { $matchingScope = null; foreach ($scopeList as $scope) { @@ -20,12 +20,12 @@ public static function getOffices() break; } } - + $providerData = [ "id" => $provider->id, "name" => $provider->displayName ?? $provider->name, ]; - + if ($matchingScope) { $providerData["scope"] = [ "id" => $matchingScope->id, @@ -40,16 +40,16 @@ public static function getOffices() "displayInfo" => $matchingScope->getDisplayInfo() ]; } - + $providerProjectionList[] = $providerData; } - + return [ "offices" => $providerProjectionList, "status" => 200 ]; } - + public static function getScopes() { @@ -429,8 +429,7 @@ public static function getBookableFreeDays(array $queryParams) ]; } catch (\Exception $e) { - //error_log('Error in AvailableDaysService: ' . $e->getMessage()); - return ExceptionService::exceptionNoAppointmentsAtLocation(); + return ExceptionService::noAppointmentsAtLocation(); } } public static function getFreeAppointments(array $params) @@ -462,13 +461,11 @@ public static function getFreeAppointments(array $params) $psr7Response = $freeSlots->getResponse(); $responseBody = (string) $psr7Response->getBody(); - $responseBody = json_decode($responseBody, true); return $responseBody['data']; } catch (\Exception $e) { - //error_log('Error in AvailableAppointmentsService: ' . $e->getMessage()); return [ 'appointmentTimestamps' => [], 'errorCode' => 'internalError', @@ -528,7 +525,7 @@ public static function getAvailableAppointments(array $queryParams) private static function processFreeSlots($freeSlots) { - + $errors = ValidationService::validateGetProcessFreeSlots($freeSlots); if (!empty($errors['errors'])) { return $errors; @@ -593,11 +590,7 @@ public static function getProcessById($processId, $authKey) } catch (\Exception $e) { if (strpos($e->getMessage(), 'kein Termin gefunden') !== false) { - return [ - 'errorCode' => 'appointmentNotFound', - 'errorMessage' => 'Termin wurde nicht gefunden.', - 'status' => 404, - ]; + return ExceptionService::appointmentNotFound(); } else { return [ 'errorCode' => 'unexpectedError', @@ -608,13 +601,18 @@ public static function getProcessById($processId, $authKey) } } + public static function updateClientData($reservedProcess) + { + + $clientUpdateResult = ZmsApiClientService::submitClientData($reservedProcess); + + if (!isset($clientUpdateResult['error'])) { + return $clientUpdateResult; + } + + return $clientUpdateResult; + } - /* Todo add method - * updateClientData - * - * - * - */ /* Todo add method * preconfirmAppointment @@ -638,4 +636,6 @@ public static function getProcessById($processId, $authKey) * */ -} \ No newline at end of file +} + + diff --git a/zmscitizenapi/tests/Zmscitizenapi/AppointmentGetTest.php b/zmscitizenapi/tests/Zmscitizenapi/AppointmentGetTest.php index 858ddc948..6eea60d26 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/AppointmentGetTest.php +++ b/zmscitizenapi/tests/Zmscitizenapi/AppointmentGetTest.php @@ -17,7 +17,7 @@ public function testRendering() 'url' => '/process/101002/fb43/', 'parameters' => [ 'resolveReferences' => 2, - ], + ], 'response' => $this->readFixture("GET_process.json") ] ] @@ -29,7 +29,7 @@ public function testRendering() ]; $response = $this->render([], $parameters, []); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ 'processId' => '101002', 'timestamp' => 1724907600, @@ -165,7 +165,7 @@ public function testMissingProcessId() ]; $response = $this->render([], $parameters, []); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ 'errors' => [ [ @@ -186,7 +186,7 @@ public function testMissingAuthKey() ]; $response = $this->render([], $parameters, []); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ 'errors' => [ [ @@ -208,7 +208,7 @@ public function testInvalidProcessId() ]; $response = $this->render([], $parameters, []); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ 'errors' => [ [ @@ -230,7 +230,7 @@ public function testInvalidAuthKey() ]; $response = $this->render([], $parameters, []); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ 'errors' => [ [ @@ -249,7 +249,7 @@ public function testBothParametersMissing() $parameters = []; $response = $this->render([], $parameters, []); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ 'errors' => [ [ @@ -277,26 +277,31 @@ public function testAppointmentNotFound() 'url' => '/process/101002/fb43/', 'parameters' => [ 'resolveReferences' => 2, - ], + ], 'exception' => new \Exception('API-Error: Zu den angegebenen Daten konnte kein Termin gefunden werden.') ] ] ); - + $parameters = [ 'processId' => '101002', 'authKey' => 'fb43', ]; - + $response = $this->render([], $parameters, []); - $responseBody = json_decode((string)$response->getBody(), true); + $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ - 'errorCode' => 'appointmentNotFound', - 'errorMessage' => 'Termin wurde nicht gefunden.', - 'status' => 404, + 'errors' => [ + [ + 'errorCode' => 'appointmentNotFound', + 'errorMessage' => 'Termin wurde nicht gefunden.', + 'status' => 404, + ] + ], + 'status' => 404 ]; $this->assertEquals(404, $response->getStatusCode()); $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); } - + } diff --git a/zmscitizenapi/tests/Zmscitizenapi/AppointmentReserveTest.php b/zmscitizenapi/tests/Zmscitizenapi/AppointmentReserveTest.php index 45dfe6e0c..a35d6b75e 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/AppointmentReserveTest.php +++ b/zmscitizenapi/tests/Zmscitizenapi/AppointmentReserveTest.php @@ -28,7 +28,7 @@ public function testRendering() [ 'function' => 'readPostResult', 'url' => '/process/status/reserved/', - 'response' => $this->readFixture("POST_reserve_timeslot.json") + 'response' => $this->readFixture("POST_reserve_appointment.json") ] ] ); @@ -44,13 +44,13 @@ public function testRendering() $response = $this->render([], $parameters, [], 'POST'); $responseBody = json_decode((string) $response->getBody(), true); $expectedResponse = [ - 'processId' => '101142', + 'processId' => '101002', 'timestamp' => 32526616522, - 'authKey' => 'b93e', - 'familyName' => '', + 'authKey' => 'fb43', + 'familyName' => 'Smith', 'customTextfield' => '', 'email' => 'test@muenchen.de', - 'telephone' => '', + 'telephone' => '123456789', 'officeName' => null, 'officeId' => '10546', 'scope' => [ diff --git a/zmscitizenapi/tests/Zmscitizenapi/AppointmentUpdateTest.php b/zmscitizenapi/tests/Zmscitizenapi/AppointmentUpdateTest.php index 48279fd9f..f079b9ac6 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/AppointmentUpdateTest.php +++ b/zmscitizenapi/tests/Zmscitizenapi/AppointmentUpdateTest.php @@ -7,8 +7,1791 @@ class AppointmentUpdateTest extends Base protected $classname = "AppointmentUpdate"; - public function testRendering() { - $responseData = $this->renderJson(method: 'POST'); - $this->assertEqualsCanonicalizing([], $responseData); + public function testRendering() + { + $this->setApiCalls( + [ + [ + 'function' => 'readGetResult', + 'url' => '/process/101002/fb43/', + 'parameters' => [ + 'resolveReferences' => 2, + ], + 'response' => $this->readFixture("GET_process.json") + ], + [ + 'function' => 'readPostResult', + 'url' => '/process/101002/fb43/', + 'response' => $this->readFixture("POST_update_appointment.json") + ] + ] + ); + + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => "test@muenchen.de", + 'telephone' => '123456789', + 'customTextfield' => "Some custom text", + ]; + + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + $expectedResponse = [ + "processId" => "101002", + "timestamp" => 1727865900, + "authKey" => "fb43", + "familyName" => "Smith", + "customTextfield" => "Some custom text", + "email" => "test@muenchen.de", + "telephone" => "123456789", + "officeName" => null, + "officeId" => null, + "scope" => [ + '$schema' => "https://schema.berlin.de/queuemanagement/scope.json", + "id" => 0, + "source" => "dldb" + ], + "subRequestCounts" => [], + "serviceId" => "10242339", + "serviceCount" => 1 + ]; + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody, true); + + } + + public function testTooManyEmailsAtLocation() + { + + $exception = new \BO\Zmsclient\Exception(); + $exception->template = 'BO\\Zmsapi\\Exception\\Process\\MoreThanAllowedAppointmentsPerMail'; + + $this->setApiCalls( + [ + [ + 'function' => 'readGetResult', + 'url' => '/process/101002/fb43/', + 'parameters' => [ + 'resolveReferences' => 2, + ], + 'response' => $this->readFixture("GET_process.json") + ], + [ + 'function' => 'readPostResult', + 'url' => '/process/101002/fb43/', + 'exception' => $exception + ] + ] + ); + + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => "test@muenchen.de", + 'telephone' => '123456789', + 'customTextfield' => "Some custom text", + ]; + + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + $expectedResponse = [ + 'errors' => [ + [ + 'errorCode' => 'tooManyAppointmentsWithSameMail', + 'errorMessage' => 'Zu viele Termine mit gleicher E-Mail- Adresse.', + 'status' => 406, + ] + ], + 'status' => 406 + ]; + + $this->assertEquals(406, $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testAppointmentNotFound() + { + $this->setApiCalls( + [ + [ + 'function' => 'readGetResult', + 'url' => '/process/101003/fb43/', + 'parameters' => [ + 'resolveReferences' => 2, + ], + 'exception' => new \Exception('API-Error: Zu den angegebenen Daten konnte kein Termin gefunden werden.') + ] + ] + ); + + $parameters = [ + 'processId' => '101003', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => "test@muenchen.de", + 'telephone' => '123456789', + 'customTextfield' => "Some custom text", + ]; + + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + $expectedResponse = [ + 'errors' => [ + [ + 'errorCode' => 'appointmentNotFound', + 'errorMessage' => 'Termin wurde nicht gefunden.', + 'status' => 404, + ] + ], + 'status' => 404 + ]; + $this->assertEquals(404, $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testInvalidProcessid_ValidAuthkey_ValidFamilyname_ValidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => null, + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'processId should be a positive 32-bit integer.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_InvalidAuthkey_ValidFamilyname_ValidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => '', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'authKey should be a non-empty string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); } + + public function testValidProcessid_ValidAuthkey_InvalidFamilyname_ValidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => '', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'familyName should be a non-empty string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_ValidFamilyname_InvalidEmail_ValidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'invalid-email', + 'telephone' => '123456789', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'email should be a valid email address.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'], + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_ValidFamilyname_ValidEmail_InvalidTelephone_ValidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123', + 'customTextfield' => 'Some custom text' + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'telephone should be a numeric string between 7 and 15 digits.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + + public function testValidProcessid_ValidAuthkey_ValidFamilyname_ValidEmail_ValidTelephone_InvalidCustomtextfield() + { + $parameters = [ + 'processId' => '101002', + 'authKey' => 'fb43', + 'familyName' => 'Smith', + 'email' => 'test@muenchen.de', + 'telephone' => '123456789', + 'customTextfield' => 123 + ]; + $response = $this->render([], $parameters, [], 'POST'); + $responseBody = json_decode((string) $response->getBody(), true); + + $expectedResponse = [ + 'errors' => [ + ['status' => 400, 'errorMessage' => 'customTextfield should be a string.'] + ], + 'status' => 400 + ]; + + $this->assertEquals($expectedResponse['status'], $response->getStatusCode()); + $this->assertEqualsCanonicalizing($expectedResponse, $responseBody); + } + } diff --git a/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_appointments_free.json b/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_appointments_free.json index 322b9e35d..1004d3fcb 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_appointments_free.json +++ b/zmscitizenapi/tests/Zmscitizenapi/fixtures/GET_appointments_free.json @@ -58,7 +58,7 @@ "apiclient": { "shortname": "default" }, - "authKey": "", + "authKey": "fb43", "createIP": "", "createTimestamp": 1725635464, "id": 0, diff --git a/zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_reserve_timeslot.json b/zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_reserve_appointment.json similarity index 94% rename from zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_reserve_timeslot.json rename to zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_reserve_appointment.json index f3d8f1840..9271cc127 100644 --- a/zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_reserve_timeslot.json +++ b/zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_reserve_appointment.json @@ -56,21 +56,21 @@ "apiclient": { "shortname": "default" }, - "authKey": "b93e", + "authKey": "fb43", "displayInfo": "Infos zum Standort.", "clients": [ { - "familyName": "", + "familyName": "Smith", "email": "test@muenchen.de", "emailSendCount": "0", "notificationsSendCount": "0", "surveyAccepted": "0", - "telephone": "" + "telephone": "123456789" } ], "createIP": "", "createTimestamp": 1727189317, - "id": "101142", + "id": "101002", "serviceCount": 1, "archiveId": 0, "queue": { @@ -78,7 +78,7 @@ "arrivalTime": 1727691300, "callCount": "0", "callTime": 0, - "number": "101142", + "number": "101002", "waitingTimeEstimate": 0, "waitingTimeOptimistic": 0, "waitingTime": null, diff --git a/zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_update_appointment.json b/zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_update_appointment.json new file mode 100644 index 000000000..065a56d58 --- /dev/null +++ b/zmscitizenapi/tests/Zmscitizenapi/fixtures/POST_update_appointment.json @@ -0,0 +1,166 @@ +{ + "$schema": "https://localhost/terminvereinbarung/api/2/", + "meta": { + "$schema": "https://schema.berlin.de/queuemanagement/metaresult.json", + "error": false, + "generated": "2024-09-24T16:48:37+02:00", + "server": "Zmsapi-ENV ()" + }, + "data": { + "$schema": "https://schema.berlin.de/queuemanagement/process.json", + "amendment": "", + "customTextfield": "Some custom text", + "appointments": [ + { + "date": 1727865900, + "scope": { + "id": "228", + "source": "dldb" + }, + "availability": { + "id": "6712", + "weekday": { + "sunday": "0", + "monday": "0", + "tuesday": "0", + "wednesday": "8", + "thursday": "0", + "friday": "0", + "saturday": "0" + }, + "repeat": { + "afterWeeks": "1", + "weekOfMonth": "0" + }, + "bookable": { + "startInDays": "0", + "endInDays": "30" + }, + "workstationCount": { + "public": "1", + "callcenter": "0", + "intern": "1" + }, + "lastChange": 1727247741, + "multipleSlotsAllowed": "1", + "slotTimeInMinutes": "5", + "startDate": 1727820000, + "endDate": 1735599600, + "startTime": "07:30:00", + "endTime": "12:50:00", + "type": "appointment", + "scope": { + "id": "228" + }, + "description": "Terminserie-Pass Mittwoch" + }, + "slotCount": "1" + } + ], + "apiclient": { + "shortname": "default" + }, + "authKey": "fb43", + "clients": [ + { + "familyName": "Smith", + "email": "test@muenchen.de", + "emailSendCount": "0", + "notificationsSendCount": "0", + "surveyAccepted": "0", + "telephone": "123456789" + } + ], + "createIP": "172.19.0.1", + "createTimestamp": "1727853590", + "id": "101002", + "archiveId": 0, + "queue": { + "$schema": "https://schema.berlin.de/queuemanagement/queue.json", + "arrivalTime": 1727865900, + "callCount": "0", + "callTime": 0, + "number": "101002", + "waitingTimeEstimate": 0, + "waitingTimeOptimistic": 0, + "waitingTime": null, + "wayTime": null, + "status": "confirmed", + "lastCallTime": 0, + "destination": null, + "destinationHint": null, + "withAppointment": "1" + }, + "reminderTimestamp": "0", + "requests": [ + { + "id": "10242339", + "link": "https://service.berlin.de/dienstleistung/10242339/", + "name": "Adressänderung Personalausweis, Reisepass, eAT", + "group": "Sonstiges", + "source": "dldb", + "data": { + "authorities": [ + { + "id": "1", + "name": "X", + "webinfo": "https://www.berlin.de/sen/finanzen/" + } + ], + "locations": [ + { + "location": "102522", + "authority": { + "id": "1", + "name": "X", + "webinfo": "https://www.berlin.de/sen/finanzen/" + }, + "url": "https://zms-demo.muenchen.de/buergeransicht/#/services/10242339/locations/102522", + "appointment": { + "link": "https://zms-demo.muenchen.de/buergeransicht/#/services/10242339/locations/102522", + "slots": "0", + "external": false, + "multiple": "1", + "allowed": true + }, + "hint": false + } + ], + "meta": { + "lastupdate": "2024-09-25T10:02:05", + "url": "https://zms-demo.muenchen.de/buergeransicht/#/services/10242339", + "locale": "de", + "keywords": "", + "translated": true, + "hash": "", + "id": "10242339" + }, + "id": "10242339", + "description": "
Es empfiehlt sich, die Adresse in sämtlichen Ausweisdokumenten gleichzeitig mit der Anmeldung zu ändern.
", + "links": [ + { + "name": "Datenschutzgrundverordnung", + "link": "https://stadt.muenchen.de/infos/dsgvo-datenschutzgrundverordnung.html", + "description": false + } + ], + "forms": [ + { + "name": "Datenschutzgrundverordnung", + "link": "https://stadt.muenchen.de/infos/dsgvo-datenschutzgrundverordnung.html", + "description": false + } + ], + "name": "Adressänderung Personalausweis, Reisepass, eAT", + "appointment": { + "link": "https://zms-demo.muenchen.de/buergeransicht/#/services/10242339" + }, + "maxQuantity": 5, + "public": true, + "fees": "gebührenfrei", + "duration": 5 + } + } + ] + } +} \ No newline at end of file