Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Behaviour/Toggles.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private function assertCheckboxState(NodeElement $toggleableElement, $expectedSt
throw new \RuntimeException(sprintf(
"Toggleable element state is '%s' but expected '%s'.",
$toggleableElement->isChecked() ? 'true' : 'false',
$expectedState ? 'true' : 'false'
$expectedState ? 'true' : 'false',
));
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/Sylius/Behat/Client/ApiPlatformClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
SharedStorageInterface $sharedStorage,
string $authorizationHeader,
string $resource,
?string $section = null
?string $section = null,
) {
$this->client = $client;
$this->sharedStorage = $sharedStorage;
Expand Down Expand Up @@ -77,7 +77,7 @@ public function show(string $id): Response
$this->resource,
$id,
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
));
}

Expand All @@ -98,7 +98,7 @@ public function delete(string $id): Response
$this->resource,
$id,
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
));
}

Expand Down Expand Up @@ -167,7 +167,7 @@ public function buildUpdateRequest(string $id): void
$this->resource,
$id,
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
);
$this->request->setContent(json_decode($this->client->getResponse()->getContent(), true));
}
Expand All @@ -179,7 +179,7 @@ public function buildCustomUpdateRequest(string $id, string $customSuffix): void
$this->resource,
sprintf('%s/%s', $id, $customSuffix),
$this->authorizationHeader,
$this->getToken()
$this->getToken(),
);
}

Expand Down Expand Up @@ -263,7 +263,7 @@ private function request(RequestInterface $request): Response
$request->parameters(),
$request->files(),
$request->headers(),
$request->content() ?? null
$request->content() ?? null,
);

return $this->getLastResponse();
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Client/ApiPlatformIriClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class ApiPlatformIriClient implements ApiIriClientInterface
public function __construct(
AbstractBrowser $client,
SharedStorageInterface $sharedStorage,
string $authorizationHeader
string $authorizationHeader,
) {
$this->client = $client;
$this->sharedStorage = $sharedStorage;
Expand All @@ -52,7 +52,7 @@ private function request(RequestInterface $request): Response
$request->parameters(),
$request->files(),
$request->headers(),
$request->content() ?? null
$request->content() ?? null,
);

return $this->client->getResponse();
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Client/ApiPlatformSecurityClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function call(): void
[],
[],
['CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json'],
json_encode($this->request['body'])
json_encode($this->request['body']),
);

$response = $this->client->getResponse();
Expand Down
28 changes: 14 additions & 14 deletions src/Sylius/Behat/Client/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ public static function index(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = $token ? ['HTTP_' . $authorizationHeader => 'Bearer ' . $token] : [];

return new self(
sprintf('/api/v2/%s%s', self::prepareSection($section), $resource),
HttpRequest::METHOD_GET,
$headers
$headers,
);
}

public static function subResourceIndex(?string $section, string $resource, string $id, string $subResource): RequestInterface
{
return new self(
sprintf('/api/v2/%s%s/%s/%s', self::prepareSection($section), $resource, $id, $subResource),
HttpRequest::METHOD_GET
HttpRequest::METHOD_GET,
);
}

Expand All @@ -67,22 +67,22 @@ public static function show(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = $token ? ['HTTP_' . $authorizationHeader => 'Bearer ' . $token] : [];

return new self(
sprintf('/api/v2/%s%s/%s', self::prepareSection($section), $resource, $id),
HttpRequest::METHOD_GET,
$headers
$headers,
);
}

public static function create(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = ['CONTENT_TYPE' => 'application/ld+json'];
if ($token !== null) {
Expand All @@ -92,7 +92,7 @@ public static function create(
return new self(
sprintf('/api/v2/%s%s', self::prepareSection($section), $resource),
HttpRequest::METHOD_POST,
$headers
$headers,
);
}

Expand All @@ -101,7 +101,7 @@ public static function update(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = ['CONTENT_TYPE' => 'application/ld+json'];
if ($token !== null) {
Expand All @@ -111,7 +111,7 @@ public static function update(
return new self(
sprintf('/api/v2/%s%s/%s', self::prepareSection($section), $resource, $id),
HttpRequest::METHOD_PUT,
$headers
$headers,
);
}

Expand All @@ -120,14 +120,14 @@ public static function delete(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = $token ? ['HTTP_' . $authorizationHeader => 'Bearer ' . $token] : [];

return new self(
sprintf('/api/v2/%s%s/%s', self::prepareSection($section), $resource, $id),
HttpRequest::METHOD_DELETE,
$headers
$headers,
);
}

Expand All @@ -141,15 +141,15 @@ public static function customItemAction(?string $section, string $resource, stri
return new self(
sprintf('/api/v2/%s%s/%s/%s', self::prepareSection($section), $resource, $id, $action),
$type,
['CONTENT_TYPE' => 'application/merge-patch+json']
['CONTENT_TYPE' => 'application/merge-patch+json'],
);
}

public static function upload(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$headers = ['CONTENT_TYPE' => 'multipart/form-data'];
if ($token !== null) {
Expand All @@ -159,7 +159,7 @@ public static function upload(
return new self(
sprintf('/api/v2/%s%s', self::prepareSection($section), $resource),
HttpRequest::METHOD_POST,
$headers
$headers,
);
}

Expand Down
12 changes: 6 additions & 6 deletions src/Sylius/Behat/Client/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static function index(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function subResourceIndex(?string $section, string $resource, string $id, string $subResource): self;
Expand All @@ -29,30 +29,30 @@ public static function show(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function create(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function update(
?string $section,
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function delete(
?string $section,
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function transition(?string $section, string $resource, string $id, string $transition): self;
Expand All @@ -63,7 +63,7 @@ public static function upload(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): self;

public static function custom(string $url, string $method, ?string $token = null): self;
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Client/ResponseChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ private function getResponseContentValue(Response $response, string $key)
$content,
SprintfResponseEscaper::provideMessageWithEscapedResponseContent(
'Content could not be parsed to array.',
$response
)
$response,
),
);

Assert::keyExists($content, $key, sprintf('Expected key "%s" not found. Received response: %s', $key, $response->getContent()));
Expand Down
Loading