Skip to content

Commit

Permalink
[API][Order] Fix coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
Loic Gouttefangeas committed Nov 2, 2023
1 parent 70a3e91 commit 828cc9d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
28 changes: 14 additions & 14 deletions src/Sylius/Behat/Context/Api/Admin/ManagingOrdersContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,31 +355,31 @@ public function theFirstOrderShouldHaveNumber(string $number)
/**
* @When I specify filter date from as :dateTime
*/
public function iSpecifyFilterDateFromAs($dateTime)
public function iSpecifyFilterDateFromAs(string $dateTime): void
{
$this->client->addFilter('checkoutCompletedAt[after]', $dateTime);
}

/**
* @When I specify filter date to as :dateTime
*/
public function iSpecifyFilterDateToAs($dateTime)
public function iSpecifyFilterDateToAs(string $dateTime): void
{
$this->client->addFilter('checkoutCompletedAt[before]', $dateTime);
}

/**
* @When I filter
*/
public function iFilter()
public function iFilter(): void
{
$this->client->filter();
}

/**
* @Then I should see :count orders in the list
*/
public function itShouldHaveAmountOfItemsInTheList($count)
public function itShouldHaveAmountOfItemsInTheList(int $count): void
{
$numberOfItems = $this->responseChecker->getValue($this->client->getLastResponse(), 'hydra:totalItems');
Assert::eq($numberOfItems, $count);
Expand All @@ -388,15 +388,15 @@ public function itShouldHaveAmountOfItemsInTheList($count)
/**
* @Then I should not see an order with :number number
*/
public function iShouldNotSeeAnOrderWithNumber($number)
public function iShouldNotSeeAnOrderWithNumber(string $number): void
{
Assert::false($this->responseChecker->hasItemWithValue($this->client->getLastResponse(), 'number', $number));
}

/**
* @When I choose :channel as a channel filter
*/
public function iChooseChannelAsAChannelFilter(ChannelInterface $channel)
public function iChooseChannelAsAChannelFilter(ChannelInterface $channel): void
{
$this->client->addFilter('channel.code', $channel->getCode());
}
Expand Down Expand Up @@ -427,7 +427,7 @@ public function iFilterByProducts(array $products): void
/**
* @When I choose :shippingMethod as a shipping method filter
*/
public function iChooseMethodAsAShippingMethodFilter(ShippingMethodInterface $shippingMethod)
public function iChooseMethodAsAShippingMethodFilter(ShippingMethodInterface $shippingMethod): void
{
$this->client->addFilter('shipments.method.code', $shippingMethod->getCode());
}
Expand All @@ -436,33 +436,33 @@ public function iChooseMethodAsAShippingMethodFilter(ShippingMethodInterface $sh
/**
* @When I choose :currency as the filter currency
*/
public function iChooseAsTheFilterCurrency(CurrencyInterface $currency)
public function iChooseAsTheFilterCurrency(CurrencyInterface $currency): void
{
$this->client->addFilter('currencyCode', $currency->getCode());
}

/**
* @Then I should not see any orders with currency :currency
*/
public function iShouldNotSeeAnyOrdersWithCurrency(CurrencyInterface $currency)
public function iShouldNotSeeAnyOrdersWithCurrency(CurrencyInterface $currency): void
{
Assert::false($this->responseChecker->hasItemWithValue($this->client->getLastResponse(), 'currencyCode', $currency->getCode()));
}

/**
* @When I specify filter total being greater than :total
*/
public function iSpecifyFilterTotalBeingGreaterThan($total)
public function iSpecifyFilterTotalBeingGreaterThan(float $total): void
{
$this->client->addFilter('total[gt]', $total* 100);
$this->client->addFilter('total[gt]', (int) ($total * 100));
}

/**
* @When I specify filter total being less than :total
*/
public function iSpecifyFilterTotalBeingLessThan($total)
public function iSpecifyFilterTotalBeingLessThan(float $total): void
{
$this->client->addFilter('total[lt]', $total* 100);
$this->client->addFilter('total[lt]', (int) ($total * 100));
}

/**
Expand All @@ -476,7 +476,7 @@ public function iFilterByVariant(ProductVariantInterface $variant): void

/**
* @When /^I filter by (variants "([^"]+)" and "([^"]+)")$/
* @param ProductVariantInterface $variants
* @param ProductVariantInterface[] $variants
*/
public function iFilterByVariants(array $variants): void
{
Expand Down
10 changes: 2 additions & 8 deletions src/Sylius/Bundle/ApiBundle/Filter/InclusiveDateRangeFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
final class InclusiveDateRangeFilter implements ContextAwareFilterInterface
{
/**
* @param ContextAwareFilterInterface $dateFilter
* @param string[] $properties
*/
public function __construct(private ContextAwareFilterInterface $dateFilter, private array $properties)
{
}


/**
* @param class-string $resourceClass
* @return array<string, mixed>
Expand All @@ -44,12 +42,8 @@ public function getDescription(string $resourceClass): array
}

/**
* @param QueryBuilder $queryBuilder
* @param QueryNameGeneratorInterface $queryNameGenerator
* @param string $resourceClass
* @param string|null $operationName
* @param class-string $resourceClass
* @param array<string, mixed> $context
* @return void
*
* @throws \Exception
*/
Expand All @@ -74,7 +68,7 @@ protected function makeDateInclusive(string $value): string

private function isExclusive(mixed $value): bool
{
if(!$value || !is_string($value)) {
if (!$value || !is_string($value)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
<attribute name="method">GET</attribute>
<attribute name="path">/admin/orders</attribute>
<attribute name="filters">
<attribute>sylius.api.order_number_filter</attribute>
<attribute>sylius.api.order_customer_filter</attribute>
<attribute>sylius.api.order_channel_filter</attribute>
<attribute>sylius.api.order_channel_order_filter</attribute>
<attribute>sylius.api.order_checkout_completed_at_filter</attribute>
<attribute>sylius.api.order_channel_filter</attribute>
<attribute>sylius.api.order_currency_code_filter</attribute>
<attribute>sylius.api.order_customer_filter</attribute>
<attribute>sylius.api.order_number_filter</attribute>
<attribute>sylius.api.order_products_filter</attribute>
<attribute>sylius.api.order_shipping_method_filter</attribute>
<attribute>sylius.api.order_currency_code_filter</attribute>
<attribute>sylius.api.order_total_filter</attribute>
<attribute>sylius.api.order_variants_filter</attribute>
</attribute>
Expand Down

0 comments on commit 828cc9d

Please sign in to comment.