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

Upgrade to Sylius 1.9 #212

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 19 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@ jobs:
tests:
runs-on: ubuntu-latest

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

strategy:
fail-fast: false
matrix:
php: [7.4, 7.3]
symfony: [^4.4, ^5.2]
sylius: [~1.8.0, ~1.9.0]
node: [10.x]
mysql: [5.7, 8.0]

exclude:
-
php: 7.3
mysql: 8.0
-
sylius: ~1.8.0
symfony: ^5.2

env:
APP_ENV: test
Expand Down Expand Up @@ -75,6 +80,18 @@ jobs:
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-

-
name: Restrict Symfony version
if: matrix.symfony != ''
run: |
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.10"
composer config extra.symfony.require "${{ matrix.symfony }}"

-
name: Restrict Sylius version
if: matrix.sylius != ''
run: composer require "sylius/sylius:${{ matrix.sylius }}" --no-update --no-scripts --no-interaction

-
name: Install PHP dependencies
run: composer install --no-interaction
Expand Down Expand Up @@ -131,7 +148,7 @@ jobs:

-
name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun
run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun

-
name: Upload Behat logs
Expand Down
50 changes: 25 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,48 @@
"license": "MIT",
"require": {
"php": "^7.3",
"knplabs/knp-snappy-bundle": "^1.7",
"knplabs/knp-snappy-bundle": "^1.8",
"ramsey/uuid": "^3.9",
"sylius/grid-bundle": "^1.7",
"sylius/resource-bundle": "^1.6",
"sylius/sylius": "^1.8",
"symfony/config": "^4.4",
"symfony/dependency-injection": "^4.4",
"symfony/form": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/http-foundation": "^4.4",
"symfony/http-kernel": "^4.4",
"symfony/messenger": "^4.4",
"symfony/options-resolver": "^4.4",
"symfony/routing": "^4.4"
"sylius/sylius": "~1.8.0 || ^1.9.0-RC.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"sylius/sylius": "~1.8.0 || ^1.9.0-RC.1",
"sylius/sylius": "~1.8.0 || ^1.9.0",

"symfony/config": "^4.4 || ^5.2",
"symfony/dependency-injection": "^4.4 || ^5.2",
"symfony/form": "^4.4 || ^5.2",
"symfony/framework-bundle": "^4.4 || ^5.2",
"symfony/http-foundation": "^4.4 || ^5.2",
"symfony/http-kernel": "^4.4 || ^5.2",
"symfony/messenger": "^4.4 || ^5.2",
"symfony/options-resolver": "^4.4 || ^5.2",
"symfony/routing": "^4.4 || ^5.2"
},
"require-dev": {
"behat/behat": "^3.6",
"behat/mink": "^1.8",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.3",
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"friends-of-behat/mink": "^1.8",
"friends-of-behat/mink-browserkit-driver": "^1.3",
"friends-of-behat/mink-extension": "^2.3",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev",
"lakion/mink-debug-extension": "^1.2.3",
"matthiasnoback/symfony-config-test": "^4.0",
"phpspec/phpspec": "^6.0",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan": "0.12.29",
"phpstan/phpstan-doctrine": "^0.12",
"phpstan/phpstan-symfony": "^0.12",
"phpstan/phpstan-webmozart-assert": "^0.12",
"phpunit/phpunit": "^8.5",
"sylius-labs/coding-standard": "^3.2",
"symfony/browser-kit": "^4.4",
"symfony/debug-bundle": "^4.4",
"symfony/dotenv": "^4.4",
"symfony/intl": "^4.4",
"symfony/web-profiler-bundle": "^4.4",
"symfony/web-server-bundle": "^4.4"
"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",
"symfony/web-server-bundle": "^4.4 || ^5.2"
},
"conflict": {
"symplify/package-builder": "^8.3.25"
Expand All @@ -66,8 +67,7 @@
"scripts": {
"analyse": [
"@composer validate --strict",
"vendor/bin/phpstan analyse -c phpstan.neon -l max src/",
"vendor/bin/ecs check src/ spec/"
"vendor/bin/phpstan analyse -c phpstan.neon -l max src/"
],
"fix": [
"vendor/bin/ecs check --fix src/ spec/"
Expand Down
2 changes: 1 addition & 1 deletion spec/EventProducer/OrderPlacedProducerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\InvoicingPlugin\EventProducer;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\UnitOfWork;
Expand Down
6 changes: 3 additions & 3 deletions spec/Generator/InvoicePdfFileGeneratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
use Sylius\InvoicingPlugin\Entity\InvoiceInterface;
use Sylius\InvoicingPlugin\Generator\InvoicePdfFileGeneratorInterface;
use Sylius\InvoicingPlugin\Model\InvoicePdf;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\Config\FileLocatorInterface;
use Twig\Environment;

final class InvoicePdfFileGeneratorSpec extends ObjectBehavior
{
function let(
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator
): void {
Expand All @@ -36,7 +36,7 @@ function it_implements_invoice_pdf_file_generator_interface(): void

function it_creates_invoice_pdf_with_generated_content_and_filename_basing_on_invoice_number(
FileLocatorInterface $fileLocator,
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
InvoiceInterface $invoice,
ChannelInterface $channel
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ final class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_invoicing_plugin');
$treeBuilder = new TreeBuilder('sylius_invoicing_plugin');
$rootNode = $treeBuilder->getRootNode();

$rootNode
->children()
Expand Down
6 changes: 3 additions & 3 deletions src/Generator/InvoicePdfFileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use Knp\Snappy\GeneratorInterface;
use Sylius\InvoicingPlugin\Entity\InvoiceInterface;
use Sylius\InvoicingPlugin\Model\InvoicePdf;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\Config\FileLocatorInterface;
use Twig\Environment;

final class InvoicePdfFileGenerator implements InvoicePdfFileGeneratorInterface
{
private const FILE_EXTENSION = '.pdf';

/** @var EngineInterface */
/** @var Environment */
private $templatingEngine;

/** @var GeneratorInterface */
Expand All @@ -30,7 +30,7 @@ final class InvoicePdfFileGenerator implements InvoicePdfFileGeneratorInterface
private $invoiceLogoPath;

public function __construct(
EngineInterface $templatingEngine,
Environment $templatingEngine,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator,
string $template,
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/services/generators.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</service>

<service id="sylius_invoicing_plugin.generator.invoice_pdf_file" class="Sylius\InvoicingPlugin\Generator\InvoicePdfFileGenerator">
<argument type="service" id="templating.engine.twig" />
<argument type="service" id="twig" />
<argument type="service" id="knp_snappy.pdf" />
<argument type="service" id="file_locator" />
<argument>@SyliusInvoicingPlugin/Invoice/Download/pdf.html.twig</argument>
Expand Down
4 changes: 4 additions & 0 deletions src/Security/Voter/InvoiceVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ protected function supports($attribute, $subject): bool
return true;
}

/**
* @param mixed $attribute
* @param mixed $subject
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
Assert::isInstanceOf($subject, InvoiceInterface::class);
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ APP_SECRET=EDITME
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://[email protected]/sylius_invoicing_plugin_%kernel.environment%?serverVersion=5.5
DATABASE_URL=mysql://[email protected]/sylius_invoicing_plugin_%kernel.environment%
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
Expand Down
2 changes: 0 additions & 2 deletions tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true],
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Sylius\Bundle\OrderBundle\SyliusOrderBundle::class => ['all' => true],
Sylius\Bundle\MoneyBundle\SyliusMoneyBundle::class => ['all' => true],
Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle::class => ['all' => true],
Expand Down Expand Up @@ -40,7 +39,6 @@
Liip\ImagineBundle\LiipImagineBundle::class => ['all' => true],
Payum\Bundle\PayumBundle\PayumBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Sylius\Bundle\FixturesBundle\SyliusFixturesBundle::class => ['all' => true],
Sylius\Bundle\PayumBundle\SyliusPayumBundle::class => ['all' => true],
Expand Down
1 change: 1 addition & 0 deletions tests/Application/config/packages/_sylius.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ imports:

- { resource: "@SyliusInvoicingPlugin/Resources/config/config.yml" }

- { resource: "@SyliusApiBundle/Resources/config/app/config.yaml" }
parameters:
sylius_core.public_dir: '%kernel.project_dir%/public'

Expand Down
1 change: 0 additions & 1 deletion tests/Application/config/packages/framework.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ framework:
secret: '%env(APP_SECRET)%'
form: true
csrf_protection: true
templating: { engines: ["twig"] }
session:
handler_id: ~
6 changes: 6 additions & 0 deletions tests/Application/config/sylius/1.8/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle::class => ['all' => true],
];
2 changes: 2 additions & 0 deletions tests/Application/config/sylius/1.8/packages/framework.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
framework:
templating: { engines: ["twig"] }
3 changes: 3 additions & 0 deletions tests/Application/config/sylius/1.8/routes/dev/twig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_errors:
resource: '@TwigBundle/Resources/config/routing/errors.xml'
prefix: /_error
6 changes: 6 additions & 0 deletions tests/Application/config/sylius/1.9/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

return [
BabDev\PagerfantaBundle\BabDevPagerfantaBundle::class => ['all' => true],
SyliusLabs\Polyfill\Symfony\Security\Bundle\SyliusLabsPolyfillSymfonySecurityBundle::class => ['all' => true],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
jms_serializer:
visitors:
json_serialization:
options:
- JSON_PRETTY_PRINT
- JSON_UNESCAPED_SLASHES
- JSON_PRESERVE_ZERO_FRACTION
json_deserialization:
options:
- JSON_PRETTY_PRINT
- JSON_UNESCAPED_SLASHES
- JSON_PRESERVE_ZERO_FRACTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jms_serializer:
visitors:
xml_serialization:
format_output: '%kernel.debug%'
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
jms_serializer:
visitors:
json_serialization:
options:
- JSON_UNESCAPED_SLASHES
- JSON_PRESERVE_ZERO_FRACTION
json_deserialization:
options:
- JSON_UNESCAPED_SLASHES
- JSON_PRESERVE_ZERO_FRACTION
6 changes: 3 additions & 3 deletions tests/Application/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

declare(strict_types=1);

use Symfony\Component\Debug\Debug;
use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;
use Tests\Sylius\InvoicingPlugin\Application\Kernel;

require __DIR__.'/../../../vendor/autoload.php';
require __DIR__ . '/../../../vendor/autoload.php';

// The check is to ensure we don't use .env in production
if (!isset($_SERVER['APP_ENV']) && !isset($_ENV['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}

$envFile = file_exists(__DIR__.'/../.env') ? __DIR__.'/../.env' : __DIR__.'/../.env.dist';
$envFile = file_exists(__DIR__ . '/../.env') ? __DIR__ . '/../.env' : __DIR__ . '/../.env.dist';
(new Dotenv())->load($envFile);
}

Expand Down
Loading