Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-144/Sylius upgrade #40

Merged
merged 42 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d9c5532
Upgraded most parts
Mar 21, 2023
5c66a16
Added webpack-encore config
Mar 21, 2023
90815bf
Added configs for mailer
Mar 21, 2023
8ae4fed
Added encore to build
Mar 21, 2023
0fd790d
Added encore to build
Mar 21, 2023
3fe7371
Split package.json
Mar 21, 2023
640a94a
Fixed phpstan
Mar 21, 2023
7130ff4
Updated node
Mar 21, 2023
b4dc62c
Added entrypoints
Mar 21, 2023
279a3ef
Moved test security.yaml to sylius1.11
Mar 21, 2023
1c41e02
Updated package.json.~1.12.0.dist
Mar 21, 2023
2abb898
Updated package.json.~1.12.0.dist
Mar 21, 2023
0e4e833
Updated package.json.~1.12.0.dist
Mar 21, 2023
b256345
Updated package.json.~1.12.0.dist
Mar 21, 2023
fc5a906
Updated package.json.~1.12.0.dist
Mar 21, 2023
db26f27
Updated package.json.~1.11.0.dist
Mar 21, 2023
b3d063a
Updated package.json.~1.11.0.dist
Mar 21, 2023
f701dad
Updated package.json.~1.11.0.dist
Mar 21, 2023
c76679e
Updated package.json.~1.11.0.dist
Mar 21, 2023
71ad2a0
Updated build
Mar 21, 2023
a75ccc5
Added webpack
Mar 21, 2023
6ef6d25
Added webpack
Mar 21, 2023
8548c44
Fixed build.yml
Mar 21, 2023
737ac2b
Upgraded most dependencies
Mar 21, 2023
c742884
Merge remote-tracking branch 'origin/feature/OP-121' into feature/OP-121
Mar 21, 2023
8f2d958
Added package.json
Mar 21, 2023
991c5bf
Updated build.yml
Mar 21, 2023
bddf609
Updated ubuntu version
Mar 21, 2023
1a609fe
Fixed chart js dependency
Mar 21, 2023
aa2c6fa
Fixed behat tests
Mar 21, 2023
de28591
Fixed phpstan
Mar 21, 2023
ee47c45
Fixed spec
Mar 21, 2023
bf1cc68
Fixed issue with 2 package.json
Mar 28, 2023
d54e4ad
Fixed typo
Mar 28, 2023
c8ec4ae
Removed line break
Mar 28, 2023
875aefd
Update tests/Application/config/packages/framework.yaml
senghe Apr 4, 2023
cbd86f7
Fixed inconsistent namings
Apr 4, 2023
cdb0a41
Merge remote-tracking branch 'origin/feature/OP-121' into feature/OP-121
Apr 4, 2023
50d6288
Added interface to typehint, and removed unused imports
Apr 6, 2023
3f413bf
Added use statement
Apr 6, 2023
ae74598
Restored typehints to old values.
Apr 6, 2023
009a19b
Removed unnecessary assets
Apr 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,23 @@ on:

jobs:
tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

name: "Sylius ${{ matrix.sylius }}, PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, MySQL ${{ matrix.mysql }}"

strategy:
fail-fast: false
matrix:
php: [7.4, 8.0]
symfony: [^4.4, ^5.2]
sylius: [~1.8.0, ~1.9.0, ~1.10.0, ~1.11.0]
node: [14.x]
mysql: [5.7]
php: [8.0]
symfony: [^5.4, ^6.0]
sylius: [~1.11.0, ~1.12.0]
node: [14.19]
mysql: [5.7, 8.0]

exclude:
-
sylius: ~1.8.0
symfony: ^5.2
-
sylius: ~1.8.0
php: 8.0
-
sylius: ~1.9.0
php: 8.0
-
sylius: ~1.11.0
senghe marked this conversation as resolved.
Show resolved Hide resolved
php: 7.4
symfony: ^6.0

env:
APP_ENV: test
Expand Down Expand Up @@ -144,13 +135,13 @@ jobs:
name: Prepare test application database
run: |
(cd tests/Application && bin/console doctrine:database:create -vvv)
(cd tests/Application && bin/console doctrine:schema:create -vvv)
(cd tests/Application && bin/console doctrine:schema:create -vvv)

-
name: Prepare test application assets
run: |
(cd tests/Application && bin/console assets:install public -vvv)
(cd tests/Application && yarn build)
(cd tests/Application && yarn encore dev)

-
name: Prepare test application cache
Expand Down
30 changes: 11 additions & 19 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"description": "Shipping data export environment for Sylius platform applications",
"license": "MIT",
"require": {
"php": "^7.3 || ^8.0",
"php": "^8.0",
"bitbag/coding-standard": "^1.0.1 || ^2.0.0",
"sylius/sylius": "~1.8.0 || ~1.9.0 || ~1.10.0 || ~1.11.0"
"doctrine/dbal": "^2.7",
"sylius/sylius": "~1.11.0 || ~1.12.0"
},
"require-dev": {
"behat/behat": "^3.6.1",
"symfony/webpack-encore-bundle": "^1.15",
"behat/mink-selenium2-driver": "^1.4",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
Expand All @@ -28,16 +30,14 @@
"phpstan/phpstan-strict-rules": "^0.12.0 || ^1.0",
"phpstan/phpstan-webmozart-assert": "0.12.12 || ^1.0",
"phpunit/phpunit": "^9.5",
"sensiolabs/security-checker": "^6.0",
"sylius-labs/coding-standard": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.2",
"symfony/debug-bundle": "^4.4 || ^5.2",
"symfony/dotenv": "^4.4 || ^5.2",
"symfony/intl": "^4.4 || ^5.2",
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"vimeo/psalm": "4.7.1",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev"
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "4.7.1 || ^5.0.0",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
},
"config": {
"sort-packages": true,
Expand All @@ -48,14 +48,6 @@
"phpstan/extension-installer": true
}
},
"conflict": {
"doctrine/dbal": "^3.0",
"symfony/symfony": "4.1.8",
"symfony/browser-kit": "4.1.8",
"symfony/dom-crawler": "4.1.8",
"symfony/routing": "4.1.8",
"symfony/doctrine-bridge": "4.4.16"
},
"autoload": {
"psr-4": {
"BitBag\\SyliusShippingExportPlugin\\": "src/",
Expand Down
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

excludes_analyse:
# Makes PHPStan crash
Expand All @@ -11,4 +12,6 @@ parameters:
- 'tests/Application/src/**.php'

ignoreErrors:
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
- '/Cannot call method [a-z]+Node\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface\|null\./'

4 changes: 4 additions & 0 deletions spec/Controller/ShippingExportDownloadLabelActionSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function it_should_not_allow_directory_travelsal(
}

function it_returns_a_streamed_response_for_label(
Filesystem $filesystem,
Request $request,
ShippingExportRepositoryInterface $repository,
ShippingExportInterface $shippingExport
Expand All @@ -59,13 +60,16 @@ function it_returns_a_streamed_response_for_label(
$repository->find(1)
->willReturn($shippingExport)
;
$filesystem->exists('/var/www/shipping_labels/label.pdf')->willReturn(true);

$this->__invoke($request)
->shouldBeAnInstanceOf(StreamedResponse::class)
;

$this->__invoke($request)
->headers->get('Content-Disposition')
->shouldReturn('attachment; filename=label.pdf')
;
}

}
5 changes: 4 additions & 1 deletion src/Controller/ShippingExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sylius\Component\Resource\Model\ResourceInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Webmozart\Assert\Assert;

final class ShippingExportController extends ResourceController
Expand All @@ -28,7 +29,9 @@ public function exportAllNewShipmentsAction(Request $request): RedirectResponse
$shippingExports = $this->repository->findAllWithNewOrPendingState();

if (0 === count($shippingExports)) {
$this->addFlash('error', 'bitbag.ui.no_new_shipments_to_export');
/** @var FlashBagInterface $flashBag */
$flashBag = $request->getSession()->getBag('flashes');
senghe marked this conversation as resolved.
Show resolved Hide resolved
$flashBag->add('error', 'bitbag.ui.no_new_shipments_to_export');

return $this->redirectToReferer($request);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/ShippingExportDownloadLabelAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace BitBag\SyliusShippingExportPlugin\Controller;

use BitBag\SyliusShippingExportPlugin\Entity\ShippingExportInterface;
use BitBag\SyliusShippingExportPlugin\Repository\ShippingExportRepositoryInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -42,6 +43,7 @@ public function __construct(

public function __invoke(Request $request): Response
{
/** @var ?ShippingExportInterface $shippingExport */
$shippingExport = $this->repository->find($request->get('id'));
Assert::notNull($shippingExport);
$labelPath = $shippingExport->getLabelPath();
Expand Down
7 changes: 7 additions & 0 deletions src/Repository/ShippingGatewayRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@

use BitBag\SyliusShippingExportPlugin\Entity\ShippingGatewayInterface;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ObjectRepository;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Sylius\Component\Shipping\Model\ShippingMethodInterface;

/**
* @template T of ResourceInterface
*
* @extends RepositoryInterface<T>
*/
interface ShippingGatewayRepositoryInterface extends RepositoryInterface
{
public function createListQueryBuilder(): QueryBuilder;
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/assets/admin/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './scss/main.scss'
import './js'
File renamed without changes.
Empty file.
2 changes: 2 additions & 0 deletions src/Resources/assets/shop/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './scss/main.scss'
import './js'
Empty file.
1 change: 1 addition & 0 deletions src/Resources/assets/shop/scss/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

4 changes: 2 additions & 2 deletions src/Resources/config/routing/bitbag_shipping_export.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ bitbag_admin_export_all_new_shipments:
path: /shipping-exports/export/all
methods: [POST, PUT]
defaults:
_controller: bitbag.controller.shipping_export:exportAllNewShipmentsAction
_controller: bitbag.controller.shipping_export::exportAllNewShipmentsAction

bitbag_admin_export_single_shipment:
path: /shipping-exports/export/{id}
methods: [POST, PUT]
defaults:
_controller: bitbag.controller.shipping_export:exportSingleShipmentAction
_controller: bitbag.controller.shipping_export::exportSingleShipmentAction

bitbag_admin_get_shipping_label:
path: /shipping-exports/label/{id}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/routing/bitbag_shipping_gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ bitbag_admin_shipping_gateway_create:
path: /shipping-gateways/new/{code}
methods: [GET, POST]
defaults:
_controller: bitbag.controller.shipping_gateway:createAction
_controller: bitbag.controller.shipping_gateway::createAction
_sylius:
section: admin
template: '@SyliusAdmin/Crud/create.html.twig'
Expand Down
12 changes: 7 additions & 5 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\RouteCollectionBuilder;

final class Kernel extends BaseKernel
Expand Down Expand Up @@ -58,7 +59,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
}
}

protected function configureRoutes(RouteCollectionBuilder $routes): void
protected function configureRoutes(RoutingConfigurator $routes): void
{
foreach ($this->getConfigurationDirectories() as $confDir) {
$this->loadRoutesConfiguration($routes, $confDir);
Expand Down Expand Up @@ -87,11 +88,11 @@ private function loadContainerConfiguration(LoaderInterface $loader, string $con
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
}

private function loadRoutesConfiguration(RouteCollectionBuilder $routes, string $confDir): void
private function loadRoutesConfiguration(RoutingConfigurator $routes, string $confDir): void
{
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS);
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS);
}

/**
Expand All @@ -103,6 +104,7 @@ private function registerBundlesFromFile(string $bundlesFile): iterable
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();

}
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/Application/assets/admin/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'sylius/bundle/AdminBundle/Resources/private/entry';
1 change: 1 addition & 0 deletions tests/Application/assets/shop/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'sylius/bundle/ShopBundle/Resources/private/entry';
2 changes: 1 addition & 1 deletion tests/Application/config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
} else {
// load all the .env files
(new Dotenv(true))->loadEnv(dirname(__DIR__) . '/.env');
(new Dotenv())->loadEnv(dirname(__DIR__) . '/.env');
}

$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
Expand Down
8 changes: 7 additions & 1 deletion tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<?php

/*
* This file was created by developers working at BitBag
* Do you need more information about us and what we do? Visit our https://bitbag.io website!
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career
*/

return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Expand Down Expand Up @@ -54,4 +59,5 @@
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all'=> true],
];
5 changes: 5 additions & 0 deletions tests/Application/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ framework:
form: true
csrf_protection: true
session:
# handler_id: 'session.handler.native_file'
senghe marked this conversation as resolved.
Show resolved Hide resolved
senghe marked this conversation as resolved.
Show resolved Hide resolved
save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
handler_id: ~
cookie_secure: auto
cookie_samesite: lax
storage_factory_id: session.storage.factory.native
9 changes: 0 additions & 9 deletions tests/Application/config/packages/security_checker.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Application/config/packages/test/framework.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
framework:
test: ~
session:
storage_id: session.storage.mock_file
handler_id: ~
7 changes: 7 additions & 0 deletions tests/Application/config/packages/webpack_encore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
webpack_encore:
output_path: '%kernel.project_dir%/public/build/default'
builds:
shop: '%kernel.project_dir%/public/build/shop'
admin: '%kernel.project_dir%/public/build/admin'
cs_shop: '%kernel.project_dir%/public/build/bitbag/cs/shop'
cs_admin: '%kernel.project_dir%/public/build/bitbag/cs/admin'
2 changes: 1 addition & 1 deletion tests/Application/config/routes/sylius_shop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ sylius_shop_default_locale:
path: /
methods: [GET]
defaults:
_controller: sylius.controller.shop.locale_switch:switchAction
_controller: sylius.controller.shop.locale_switch::switchAction
6 changes: 0 additions & 6 deletions tests/Application/config/sylius/1.10/bundles.php

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading