Skip to content

Commit

Permalink
Fix dependencies and coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Jun 13, 2024
1 parent e1b30b7 commit 52b750e
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 12 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ jobs:
run: "(cd tests/Application && bin/console doctrine:schema:validate -vvv)" # The verbose flag will show 'missing' SQL statements, if any

- name: "Load fixtures for functional tests"
run: "(cd tests/Application && bin/console doctrine:fixtures:load --no-interaction)"
run: "(cd tests/Application && bin/console sylius:fixtures:load --no-interaction)"

- name: "Run yarn"
run: "(cd tests/Application && yarn install && yarn build)"

- name: "Run phpunit"
run: "composer functional-tests"
Expand Down
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
],
"require": {
"php": ">=8.1",
"doctrine/orm": "^2.0 || ^3.0",
"doctrine/persistence": "^2.0 || ^3.0",
"sylius/core": "^1.0",
"sylius/core-bundle": "^1.0",
Expand All @@ -18,11 +19,13 @@
"sylius/resource-bundle": "^1.6",
"symfony/config": "^5.4 || ^6.4 || ^7.0",
"symfony/dependency-injection": "^5.4 || ^6.4 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.4 || ^7.0",
"symfony/event-dispatcher": "^5.4 || ^6.4 || ^7.0",
"symfony/form": "^5.4 || ^6.4 || ^7.0",
"symfony/http-foundation": "^5.4 || ^6.4 || ^7.0",
"symfony/http-kernel": "^5.4 || ^6.4 || ^7.0",
"symfony/options-resolver": "^5.4 || ^6.4 || ^7.0",
"symfony/routing": "^5.4 || ^6.4 || ^7.0",
"webmozart/assert": "^1.11"
},
"require-dev": {
Expand All @@ -39,7 +42,7 @@
"psalm/plugin-phpunit": "^0.18.4",
"setono/code-quality-pack": "^2.7",
"sylius/sylius": "~1.12.13",
"symfony/browser-kit": "^7.1",
"symfony/browser-kit": "^5.4",
"symfony/debug-bundle": "^5.4 || ^6.4 || ^7.0",
"symfony/dotenv": "^5.4 || ^6.4 || ^7.0",
"symfony/intl": "^5.4 || ^6.4 || ^7.0",
Expand Down Expand Up @@ -82,7 +85,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
1 change: 0 additions & 1 deletion src/Form/Extension/OrderTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Setono\SyliusOrderEditPlugin\Form\Type\OrderItemCollectionType;
use Sylius\Bundle\OrderBundle\Form\Type\OrderType;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;

Expand Down
1 change: 0 additions & 1 deletion src/Form/Type/OrderItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Sylius\Component\Order\Modifier\OrderItemQuantityModifierInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;

final class OrderItemType extends AbstractResourceType
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;
}
}
7 changes: 4 additions & 3 deletions 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,11 +51,11 @@ 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'],
$content
$content,
);

self::assertResponseStatusCodeSame(302);
Expand All @@ -68,7 +69,7 @@ public function testItUpdatesOrder(): void

private function placeOrderProgramatically(
string $variantCode = '000F_office_grey_jeans-variant-0',
int $quantity = 1
int $quantity = 1,
): Order {
/** @var MessageBusInterface $commandBus */
$commandBus = self::getContainer()->get('sylius.command_bus');
Expand Down

0 comments on commit 52b750e

Please sign in to comment.