Skip to content

Commit

Permalink
Update to latest version of libraries, fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax committed Mar 16, 2024
1 parent 66c93e3 commit 328c03e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 27 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/ApiPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
private \Nette\Http\IRequest $request,
private \Nette\Http\IResponse $response,
private \Graphpinator\Nette\NetteCache $cache,
private bool $debugMode = false,
bool $debugMode = false,
)
{
$this->graphpinator = new \Graphpinator\Graphpinator(
Expand All @@ -24,7 +24,7 @@ public function __construct(
? \Graphpinator\ErrorHandlingMode::OUTPUTABLE
: \Graphpinator\ErrorHandlingMode::ALL,
new \Graphpinator\Module\ModuleSet([
new \Graphpinator\QueryCost\MaxDepthModule(15),
//new \Graphpinator\QueryCost\MaxDepthModule(15),
new \Graphpinator\PersistedQueries\PersistedQueriesModule($schema, $this->cache),
]),
new \Graphpinator\Nette\TracyLogger(),
Expand Down
8 changes: 6 additions & 2 deletions src/FileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,23 @@ public function __construct(
{
}

public function getMap() : ?\Infinityloop\Utils\Json\MapJson
public function getMap() : ?\Infinityloop\Utils\Json
{
$map = $this->request->getPost('map');

return \is_string($map)
? \Infinityloop\Utils\Json\MapJson::fromString($map)
? \Infinityloop\Utils\Json::fromString($map)
: null;
}

public function getFile(string $key) : \Psr\Http\Message\UploadedFileInterface
{
$file = $this->request->getFile($key);

if (!$file instanceof \Nette\Http\FileUpload) {
throw new \LogicException();
}

return new \GuzzleHttp\Psr7\UploadedFile(
$file->getTemporaryFile(),
$file->getSize(),
Expand Down
34 changes: 17 additions & 17 deletions tests/Unit/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public function testJsonBody() : void
{
$httpRequest = new \Nette\Http\Request(
new \Nette\Http\UrlScript(),
null,
null,
null,
[],
[],
[],
['Content-Type' => 'application/json'],
'GET',
null,
Expand All @@ -32,9 +32,9 @@ public function testGraphqlBody() : void
{
$httpRequest = new \Nette\Http\Request(
new \Nette\Http\UrlScript(),
null,
null,
null,
[],
[],
[],
['Content-Type' => 'application/graphql'],
'GET',
null,
Expand Down Expand Up @@ -67,8 +67,8 @@ public function testMultipart() : void
$httpRequest = new \Nette\Http\Request(
new \Nette\Http\UrlScript(),
['map' => '[]', 'operations' => '{"query":"query {}", "variables":{"var1":"varValue"}, "operationName":"opName"}'],
null,
null,
[],
[],
['Content-Type' => 'multipart/form-data; boundary=--------boundary'],
'POST',
);
Expand All @@ -85,10 +85,10 @@ public function testInvalidMethod() : void

$httpRequest = new \Nette\Http\Request(
new \Nette\Http\UrlScript(),
null,
null,
null,
null,
[],
[],
[],
[],
'PATCH',
);
(new \Graphpinator\Nette\NetteRequestFactory($httpRequest))->create();
Expand All @@ -101,8 +101,8 @@ public function testInvalidMultipartGet() : void
$httpRequest = new \Nette\Http\Request(
new \Nette\Http\UrlScript(),
['map' => '[]', 'operations' => '{"query":"query {}", "variables":{"var1":"varValue"}, "operationName":"opName"}'],
null,
null,
[],
[],
['Content-Type' => 'multipart/form-data; boundary=--------boundary'],
'GET',
);
Expand All @@ -115,9 +115,9 @@ public function testInvalidStrict() : void

$httpRequest = new \Nette\Http\Request(
new \Nette\Http\UrlScript(),
null,
null,
null,
[],
[],
[],
['Content-Type' => 'application/json'],
'GET',
null,
Expand Down

0 comments on commit 328c03e

Please sign in to comment.