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

Allow for Sylius 1.8 & 1.9 and Symfony 4.4 & 5.2 #254

Merged
merged 12 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from 11 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
43 changes: 34 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,26 @@ on:

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

name: "PHP ${{ matrix.php }}, MySQL ${{ matrix.mysql }}, Sylius ${{ matrix.sylius }}"
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@beta]
GSadee marked this conversation as resolved.
Show resolved Hide resolved
node: [10.x]
mysql: [5.7, 8.0]
sylius: [1.8.*]

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

env:
APP_ENV: test
Expand Down Expand Up @@ -92,15 +96,23 @@ jobs:
restore-keys: |
${{ runner.os }}-php-${{ matrix.php }}-composer-

- name: Prepare migrations
run: |
composer require sylius-labs/doctrine-migrations-extra-bundle --no-interaction --no-update

-
name: Install Sylius version
run: |
composer require "sylius/sylius:${{ matrix.sylius }}" --no-update

-
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 update --no-interaction
Expand All @@ -124,9 +136,22 @@ jobs:
run: (cd tests/Application && yarn install)

-
name: Prepare test application database
name: Create test application database
run: |
(cd tests/Application && bin/console doctrine:database:create -vvv)

-
name: Exclude duplicated migrations
if: matrix.sylius != '~1.8.0'
run: |
(cd tests/Application && bin/console doctrine:migration:sync-metadata-storage)
(cd tests/Application && bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201130071338' --add)
GSadee marked this conversation as resolved.
Show resolved Hide resolved
(cd tests/Application && bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201204071301' --add)
(cd tests/Application && bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201208105207' --add)

-
name: Prepare test application database
run: |
(cd tests/Application && bin/console doctrine:migrations:migrate -n -vvv -q)

-
Expand Down Expand Up @@ -161,7 +186,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
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,28 @@ It is used by `KnpSnappyBundle` and can be configured according to [their documm

> Remember to allow community recipes with `composer config extra.symfony.allow-contrib true` or during plugin installation process

2. Apply migration to your database:
2. If you install the plugin on Sylius 1.9 or higher, exclude duplicated migrations:

```bash
bin/console doctrine:migration:sync-metadata-storage
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201130071338' --add
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201204071301' --add
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201208105207' --add
```

3. Apply migration to your database:

```bash
bin/console doctrine:migrations:migrate
```

3. Copy Sylius templates overridden in plugin to your templates directory (e.g `templates/bundles/`):
4. Copy Sylius templates overridden in plugin to your templates directory (e.g `templates/bundles/`):

```bash
mkdir -p templates/bundles/SyliusAdminBundle/
cp -R vendor/sylius/refund-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
```

4. (optional) If you don't use `symfony/messenger` component yet, it is required to configure one of the message buses as a default bus:

```yaml
framework:
messenger:
default_bus: sylius_refund_plugin.command_bus
```

#### Beware!

This installation instruction assumes that you're using Symfony Flex. If you don't, take a look at the
Expand Down
9 changes: 9 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201208105207' --add
```

1. If you upgrade also Sylius to 1.9 version, exclude duplicated migrations:

```bash
bin/console doctrine:migration:sync-metadata-storage
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201130071338' --add
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201204071301' --add
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201208105207' --add
```

1. Add traits that enhance Adjustment and Shipment models from Sylius. These traits are not covered by
the backward compatibility promise and it will be removed after update Sylius to 1.9. It is a duplication of a logic
from Sylius to provide proper adjustments handling.
Expand Down
22 changes: 11 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,33 @@
"knplabs/knp-snappy-bundle": "^1.7",
"myclabs/php-enum": "^1.7",
"sylius/resource-bundle": "^1.6",
"sylius/sylius": "^1.8",
"symfony/messenger": "^4.4"
"sylius/sylius": "~1.8.0 || ~1.9.0@beta",
"symfony/messenger": "^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/mink-selenium2-driver": "^1.4",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"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",
"phpspec/phpspec": "^6.0",
"phpstan/phpstan": "0.12.29",
"phpstan/phpstan-webmozart-assert": "0.12.6",
"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"
},
"autoload": {
"psr-4": {
Expand Down
24 changes: 12 additions & 12 deletions docs/legacy_installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,30 @@
options: []
````

6. Copy plugin migrations to your migrations directory (e.g. `src/Migrations`) and apply them to your database:
6. If you install the plugin on Sylius 1.9 or higher, exclude duplicated migrations:

```bash
bin/console doctrine:migration:sync-metadata-storage
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201130071338' --add
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201204071301' --add
bin/console doctrine:migrations:version 'Sylius\RefundPlugin\Migrations\Version20201208105207' --add
```

7. Apply migrations to your database:

```bash
cp -R vendor/sylius/refund-plugin/migrations/* src/Migrations
bin/console doctrine:migrations:migrate
```

7. Copy Sylius templates overridden in plugin to your templates directory (e.g `templates/bundles/`):
8. Copy Sylius templates overridden in plugin to your templates directory (e.g `templates/bundles/`):

```bash
mkdir -p templates/bundles/SyliusAdminBundle/
cp -R vendor/sylius/refund-plugin/src/Resources/views/SyliusAdminBundle/* templates/bundles/SyliusAdminBundle/
```

8. Clear cache:
9. Clear cache:

```bash
bin/console cache:clear
```

9. (optional) If you don't use `symfony/messenger` component yet, it is required to configure one of the message buses as a default bus:

```yaml
framework:
messenger:
default_bus: sylius_refund_plugin.command_bus
```
2 changes: 1 addition & 1 deletion spec/CommandHandler/GenerateCreditMemoHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\CommandHandler;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
Expand Down
2 changes: 1 addition & 1 deletion spec/Creator/RefundCreatorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\Creator;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Sylius\RefundPlugin\Creator\RefundCreatorInterface;
use Sylius\RefundPlugin\Entity\RefundInterface;
Expand Down
6 changes: 3 additions & 3 deletions spec/Generator/CreditMemoPdfFileGeneratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
use Sylius\RefundPlugin\Generator\CreditMemoPdfFileGeneratorInterface;
use Sylius\RefundPlugin\Model\CreditMemoPdf;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Templating\EngineInterface;
use Twig\Environment;

final class CreditMemoPdfFileGeneratorSpec extends ObjectBehavior
{
function let(
RepositoryInterface $creditMemoRepository,
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator
): void {
Expand All @@ -39,7 +39,7 @@ function it_implements_credit_memo_pdf_file_generator_interface(): void

function it_creates_credit_memo_pdf_with_generated_content_and_filename_basing_on_credit_memo_number(
RepositoryInterface $creditMemoRepository,
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator,
CreditMemoInterface $creditMemo
Expand Down
2 changes: 1 addition & 1 deletion spec/Generator/SequentialNumberGeneratorSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\Generator;

use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\Persistence\ObjectRepository;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\EntityManagerInterface;
use PhpSpec\ObjectBehavior;
Expand Down
2 changes: 1 addition & 1 deletion spec/StateResolver/OrderFullyRefundedStateResolverSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\StateResolver;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use SM\Factory\FactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\StateResolver;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use SM\Factory\FactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace spec\Sylius\RefundPlugin\StateResolver;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use PhpSpec\ObjectBehavior;
use SM\Factory\FactoryInterface as StateMachineFactoryInterface;
use SM\StateMachine\StateMachineInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Action/CompleteRefundPaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\Action;

use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\Persistence\ObjectRepository;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\RefundPlugin\Entity\RefundPaymentInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/CommandHandler/GenerateCreditMemoHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\CommandHandler;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\RefundPlugin\Command\GenerateCreditMemo;
Expand Down
2 changes: 1 addition & 1 deletion src/Creator/RefundCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\Creator;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Sylius\RefundPlugin\Exception\UnitAlreadyRefundedException;
use Sylius\RefundPlugin\Factory\RefundFactoryInterface;
use Sylius\RefundPlugin\Model\RefundType;
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ final class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('sylius_refund_plugin');

return $treeBuilder;
return new TreeBuilder('sylius_refund_plugin');
}
}
6 changes: 3 additions & 3 deletions src/Generator/CreditMemoPdfFileGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Sylius\RefundPlugin\Exception\CreditMemoNotFound;
use Sylius\RefundPlugin\Model\CreditMemoPdf;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Templating\EngineInterface;
use Twig\Environment;

final class CreditMemoPdfFileGenerator implements CreditMemoPdfFileGeneratorInterface
{
Expand All @@ -19,7 +19,7 @@ final class CreditMemoPdfFileGenerator implements CreditMemoPdfFileGeneratorInte
/** @var RepositoryInterface */
private $creditMemoRepository;

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

/** @var GeneratorInterface */
Expand All @@ -36,7 +36,7 @@ final class CreditMemoPdfFileGenerator implements CreditMemoPdfFileGeneratorInte

public function __construct(
RepositoryInterface $creditMemoRepository,
EngineInterface $twig,
Environment $twig,
GeneratorInterface $pdfGenerator,
FileLocatorInterface $fileLocator,
string $template,
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/SequentialNumberGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Sylius\RefundPlugin\Generator;

use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\Persistence\ObjectRepository;
use Doctrine\DBAL\LockMode;
use Doctrine\ORM\EntityManagerInterface;
use Sylius\RefundPlugin\Entity\CreditMemoSequenceInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/admin_routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sylius_refund_credit_memo:
resource: |
alias: sylius_refund.credit_memo
section: admin
templates: SyliusAdminBundle:Crud
templates: "@SyliusAdmin\\Crud"
only: ['index']
grid: sylius_refund_credit_memo
permission: true
Expand Down
Loading