Skip to content

Commit

Permalink
fix(compatibility-suite): Fix unknown 500 error cause missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Oct 20, 2024
1 parent dd6eefd commit e0df3c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compatibility-suite/public/generators/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
$app = new FrameworkX\App();

$app->put('/request-generators', function (ServerRequestInterface $request) {
$error = 'no error';
try {
file_put_contents(__DIR__ . '/body.json', $request->getBody()->getContents());
file_put_contents(__DIR__ . '/headers.json', json_encode($request->getHeaders()));
file_put_contents(__DIR__ . '/queryParams.json', json_encode($request->getQueryParams()));
} catch (\Exception $e) {
$error = $e->getMessage();
throw $e;
} finally {
file_put_contents(__DIR__ . '/debug.txt', $error);
}

return new Response();
});
Expand Down
4 changes: 4 additions & 0 deletions compatibility-suite/tests/Service/GeneratorServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,27 @@ public function getPort(): int

public function getBody(): string
{
echo file_get_contents(Path::PUBLIC_PATH . '/generators/debug.txt');
return @file_get_contents($this->bodyFile);
}

public function getPath(): string
{
echo file_get_contents(Path::PUBLIC_PATH . '/generators/debug.txt');
return file_get_contents($this->pathFile);
}

public function getHeader(string $header): array
{
echo file_get_contents(Path::PUBLIC_PATH . '/generators/debug.txt');
$headers = json_decode(file_get_contents($this->headersFile), true);

return $headers[$header] ?? [];
}

public function getQueryParam(string $name): string
{
echo file_get_contents(Path::PUBLIC_PATH . '/generators/debug.txt');
$queryParams = json_decode(file_get_contents($this->queryParamsFile), true);

return $queryParams[$name] ?? '';
Expand Down

0 comments on commit e0df3c2

Please sign in to comment.