Skip to content

Commit

Permalink
[CS][DX] Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylius Bot authored Jun 20, 2022
1 parent b9698a8 commit 384f502
Show file tree
Hide file tree
Showing 1,174 changed files with 4,021 additions and 3,966 deletions.
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
16 changes: 8 additions & 8 deletions src/Sylius/Behat/Client/ApiPlatformClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(
private SharedStorageInterface $sharedStorage,
private RequestFactoryInterface $requestFactory,
private string $authorizationHeader,
private ?string $section = null
private ?string $section = null,
) {
}

Expand Down Expand Up @@ -63,8 +63,8 @@ public function show(string $resource, string $id): Response
$resource,
$id,
$this->authorizationHeader,
$this->getToken()
)
$this->getToken(),
),
);
}

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

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

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

return $this->getLastResponse();
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 @@ -53,7 +53,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
12 changes: 6 additions & 6 deletions src/Sylius/Behat/Client/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function index(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$builder = RequestBuilder::create(
sprintf('%s/%s/%s', $this->apiUrlPrefix, $section, $resource),
Expand Down Expand Up @@ -62,7 +62,7 @@ public function show(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$builder = RequestBuilder::create(
sprintf('%s/%s/%s/%s', $this->apiUrlPrefix, $section, $resource, $id),
Expand All @@ -81,7 +81,7 @@ public function create(
string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$builder = RequestBuilder::create(
sprintf('%s/%s/%s', $this->apiUrlPrefix, $section, $resource),
Expand All @@ -102,7 +102,7 @@ public function update(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$builder = RequestBuilder::create(
sprintf('%s/%s/%s/%s', $this->apiUrlPrefix, $section, $resource, $id),
Expand All @@ -123,7 +123,7 @@ public function delete(
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$builder = RequestBuilder::create(
sprintf('%s/%s/%s/%s', $this->apiUrlPrefix, $section, $resource, $id),
Expand Down Expand Up @@ -159,7 +159,7 @@ public function upload(
string $resource,
array $files,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface {
$builder = RequestBuilder::create(
sprintf('%s/%s/%s', $this->apiUrlPrefix, $section, $resource),
Expand Down
20 changes: 10 additions & 10 deletions src/Sylius/Behat/Client/RequestFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,74 +19,74 @@ public function index(
?string $section,
string $resource,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface;

public function subResourceIndex(
string $section,
string $resource,
string $id,
string $subResource
string $subResource,
): RequestInterface;

public function show(
string $section,
string $resource,
string $id,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface;

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

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

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

public function upload(
string $section,
string $resource,
array $files,
string $authorizationHeader,
?string $token = null
?string $token = null,
): RequestInterface;

public function transition(
string $section,
string $resource,
string $id,
string $transition
string $transition,
): RequestInterface;

public function customItemAction(
string $section,
string $resource,
string $id,
string $type,
string $action
string $action,
): RequestInterface;

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

Assert::keyExists(
$content,
$key,
SprintfResponseEscaper::provideMessageWithEscapedResponseContent(
'Expected \'' . $key . '\' not found.',
$response
)
$response,
),
);

return $content[$key];
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Behat/Context/Api/Admin/AjaxContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function iLookForVariantWithDescriptorWithinProduct($phrase, ProductInter
'/admin/ajax/product-variants/search',
['phrase' => $phrase, 'productCode' => $product->getCode()],
[],
['ACCEPT' => 'application/json']
['ACCEPT' => 'application/json'],
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function theAdministratorShouldAppearInTheStore(string $email): void
{
Assert::true(
$this->responseChecker->hasItemWithValue($this->client->index(Resources::ADMINISTRATORS), 'email', $email),
sprintf('Administrator with email %s does not exist', $email)
sprintf('Administrator with email %s does not exist', $email),
);
}

Expand All @@ -203,7 +203,7 @@ public function thereShouldNotBeAdministratorAnymore(string $email): void
{
Assert::false(
$this->responseChecker->hasItemWithValue($this->client->index(Resources::ADMINISTRATORS), 'email', $email),
sprintf('Administrator with email %s exists, but it should not', $email)
sprintf('Administrator with email %s exists, but it should not', $email),
);
}

Expand All @@ -215,7 +215,7 @@ public function thereShouldStillBeOnlyOneAdministratorWithAnEmail(string $email)
Assert::count(
$this->responseChecker->getCollectionItemsWithValue($this->client->index(Resources::ADMINISTRATORS), 'email', $email),
1,
sprintf('There is more than one administrator with email %s', $email)
sprintf('There is more than one administrator with email %s', $email),
);
}

Expand All @@ -228,7 +228,7 @@ public function thisAdministratorWithNameShouldAppearInTheStore(string $username
Assert::count(
$this->responseChecker->getCollectionItemsWithValue($this->client->index(Resources::ADMINISTRATORS), 'username', $username),
1,
sprintf('There is more than one administrator with username %s', $username)
sprintf('There is more than one administrator with username %s', $username),
);
}

Expand All @@ -239,7 +239,7 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyCreated(): void
{
Assert::true(
$this->responseChecker->isCreationSuccessful($this->client->getLastResponse()),
'Administrator could not be created'
'Administrator could not be created',
);
}

Expand All @@ -250,7 +250,7 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyEdited(): void
{
Assert::true(
$this->responseChecker->isUpdateSuccessful($this->client->getLastResponse()),
'Administrator could not be edited'
'Administrator could not be edited',
);
}

Expand All @@ -261,7 +261,7 @@ public function iShouldBeNotifiedThatItHasBeenSuccessfullyDeleted(): void
{
Assert::true(
$this->responseChecker->isDeletionSuccessful($this->client->getLastResponse()),
'Administrator could not be deleted'
'Administrator could not be deleted',
);
}

Expand All @@ -272,7 +272,7 @@ public function iShouldBeNotifiedThatEmailMustBeUnique(): void
{
Assert::contains(
$this->responseChecker->getError($this->client->getLastResponse()),
'email: This email is already used.'
'email: This email is already used.',
);
}

Expand All @@ -283,7 +283,7 @@ public function iShouldBeNotifiedThatNameMustBeUnique(): void
{
Assert::contains(
$this->responseChecker->getError($this->client->getLastResponse()),
'username: This username is already used.'
'username: This username is already used.',
);
}

Expand All @@ -294,7 +294,7 @@ public function iShouldBeNotifiedThatFirstNameIsRequired(string $elementName): v
{
Assert::contains(
$this->responseChecker->getError($this->client->getLastResponse()),
sprintf('Please enter your %s.', $elementName)
sprintf('Please enter your %s.', $elementName),
);
}

Expand All @@ -305,7 +305,7 @@ public function iShouldBeNotifiedThatEmailIsNotValid(): void
{
Assert::contains(
$this->responseChecker->getError($this->client->getLastResponse()),
'email: This email is invalid.'
'email: This email is invalid.',
);
}

Expand All @@ -316,11 +316,11 @@ public function iShouldBeNotifiedThatItCannotBeDeleted(): void
{
Assert::false(
$this->responseChecker->isDeletionSuccessful($this->client->getLastResponse()),
'Administrator could be deleted'
'Administrator could be deleted',
);
Assert::same(
$this->responseChecker->getError($this->client->getLastResponse()),
'Cannot remove currently logged in user.'
'Cannot remove currently logged in user.',
);
}

Expand All @@ -332,7 +332,7 @@ public function iShouldSeeTheImageAsMyAvatar(string $avatar, AdminUserInterface
Assert::true($this->responseChecker->hasValue(
$this->client->show(Resources::ADMINISTRATORS, (string) $administrator->getId()),
'avatar',
$this->sharedStorage->get(StringInflector::nameToCode($avatar))
$this->sharedStorage->get(StringInflector::nameToCode($avatar)),
));
}

Expand All @@ -347,7 +347,7 @@ public function iShouldNotSeeTheAvatarImage(string $avatar): void
Assert::true($this->responseChecker->hasValue(
$this->client->show(Resources::ADMINISTRATORS, (string) $administrator->getId()),
'avatar',
null
null,
));
}

Expand Down
Loading

0 comments on commit 384f502

Please sign in to comment.