Skip to content

Commit

Permalink
Fix coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jun 13, 2024
1 parent 784b444 commit 000f5e2
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"analyse": "psalm",
"check-style": "ecs check",
"fix-style": "ecs check --fix",
"unit-tests": "vendor/bin/phpunit tests/Unit/",
"functional-tests": "vendor/bin/phpunit tests/Functional/"
"functional-tests": "vendor/bin/phpunit tests/Functional/",
"unit-tests": "vendor/bin/phpunit tests/Unit/"
}
}
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<directory name="tests"/>
<ignoreFiles>
<directory name="tests/Application"/>
<directory name="tests/Functional"/>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>
Expand Down
5 changes: 4 additions & 1 deletion src/Controller/EditOrderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

final class EditOrderAction
Expand Down Expand Up @@ -59,7 +60,9 @@ private function addFlashAndRedirect(
int $orderId,
): RedirectResponse {
$session = $this->requestStack->getSession();
$session->getBag('flashes')->add($type, $message);
/** @var FlashBagInterface $flashBag */
$flashBag = $session->getBag('flashes');
$flashBag->add($type, $message);

return new RedirectResponse($this->router->generate($route, ['id' => $orderId]));
}
Expand Down
3 changes: 2 additions & 1 deletion src/Provider/OldOrderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public function __construct(

public function provide(int $orderId): OrderInterface
{
/** @var OrderInterface|null $order */
$order = $this->orderRepository->find($orderId);
Assert::notNull($order);
Assert::isInstanceOf($order, OrderInterface::class);

$this->orderInventoryOperator->cancel($order);

Expand Down
6 changes: 5 additions & 1 deletion src/Provider/UpdatedOrderProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Sylius\Component\Core\Model\OrderInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Webmozart\Assert\Assert;

final class UpdatedOrderProvider
{
Expand All @@ -20,6 +21,9 @@ public function fromRequest(OrderInterface $order, Request $request): OrderInter
$form = $this->formFactory->create(OrderType::class, $order, ['validation_groups' => 'sylius']);
$form->handleRequest($request);

return $form->getData();
$data = $form->getData();
Assert::isInstanceOf($data, OrderInterface::class);

return $data;
}
}
3 changes: 2 additions & 1 deletion tests/Functional/OrderUpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function testItUpdatesOrder(): void
$this->makeVariantTrackedWithStock();
$order = $this->placeOrderProgramatically(quantity: 5);

/** @var ProductVariantInterface $variant */
$variant = $this->getVariantRepository()->findOneBy(['code' => '000F_office_grey_jeans-variant-0']);
$initialHold = $variant->getOnHold();

Expand All @@ -50,7 +51,7 @@ public function testItUpdatesOrder(): void

self::$client->request(
'PATCH',
sprintf('/admin/orders/%d/update-and-processs', $order->getId()),
sprintf('/admin/orders/%d/update-and-processs', (int) $order->getId()),
[],
[],
['CONTENT_TYPE' => 'application/json'],
Expand Down

0 comments on commit 000f5e2

Please sign in to comment.