Skip to content

Commit

Permalink
Merge pull request #49 from BitBagCommerce/feature/OP-376-add-sylius-…
Browse files Browse the repository at this point in the history
…1.13-support

Feature/op 376 add sylius 1.13 support
  • Loading branch information
senghe authored Jul 25, 2024
2 parents 32412f5 + a176347 commit 6b3a7ae
Show file tree
Hide file tree
Showing 108 changed files with 779 additions and 871 deletions.
43 changes: 19 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,29 @@ on:

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

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

strategy:
fail-fast: false
matrix:
php: [8.0]
symfony: [^5.4, ^6.0]
sylius: [~1.11.0, ~1.12.0]
node: [14.19]
mysql: [5.7, 8.0]

php: ["8.0", "8.1", "8.2", "8.3"]
symfony: ["^5.4", "^6.0"]
sylius: ["~1.12.0", "~1.13.0"]
node: ["20.x"]
mysql: ["8.0"]
exclude:
-
sylius: ~1.11.0
symfony: ^6.0
-
sylius: ~1.11.0
php: 7.3
-
sylius: ~1.11.0
php: 7.4
- sylius: "~1.13.0"
php: "8.0"

env:
APP_ENV: test
DATABASE_URL: "mysql://root:[email protected]/sylius?serverVersion=${{ matrix.mysql }}"

steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v3

-
name: Setup PHP
Expand All @@ -57,7 +49,7 @@ jobs:

-
name: Setup Node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: "${{ matrix.node }}"

Expand Down Expand Up @@ -95,7 +87,7 @@ jobs:

-
name: Cache Composer
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json **/composer.lock') }}
Expand All @@ -120,7 +112,7 @@ jobs:
-
name: Get Yarn cache directory
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT

-
name: Cache Yarn
Expand Down Expand Up @@ -160,6 +152,10 @@ jobs:
name: Validate database schema
run: (cd tests/Application && bin/console doctrine:schema:validate)

-
name: Run ECS
run: vendor/bin/ecs check src

-
name: Run PHPStan
if: matrix.php != 8.0
Expand All @@ -169,21 +165,20 @@ jobs:
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction


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

-
name: Upload Behat logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: failure()
with:
name: Behat logs
path: etc/build/
if-no-files-found: ignore
-

-
name: Failed build Slack notification
uses: rtCamp/action-slack-notify@v2
if: ${{ failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') }}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Like what we do? Want to join us? Check out our job listings on our [career page

* [Overview](#overview)
* [Support](#we-are-here-to-help)
* [Installation](doc/installation.md)
* [Screenshots](#screenshots)
* [About us](#about-us)
* [Community](#community)
Expand Down
22 changes: 14 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"description": "Bonus points plugin for Sylius.",
"license": "MIT",
"require": {
"php": "^8.0",
"sylius/sylius": "~1.11.0 || ~1.12.0"
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3",
"sylius/sylius": "~1.12.0 || ~1.13.0"
},
"require-dev": {
"symfony/webpack-encore-bundle": "^1.14",
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"bitbag/coding-standard": "^3.0",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
Expand All @@ -27,18 +27,24 @@
"lakion/mink-debug-extension": "^2.0.0",
"phpspec/phpspec": "^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "0.12.88",
"phpstan/phpstan-doctrine": "0.12.37",
"phpstan/phpstan-strict-rules": "^0.12.0",
"phpstan/phpstan-webmozart-assert": "0.12.12",
"phpstan/phpstan": "1.4",
"phpstan/phpstan-doctrine": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^9.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"sylius-labs/coding-standard": "^4.0",
"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",
"polishsymfonycommunity/symfony-mocker-container": "^1.0"
"symfony/webpack-encore-bundle": "^1.14",
"doctrine/persistence": "^3.0"
},
"conflict": {
"behat/mink-selenium2-driver": ">=1.7.0",
"doctrine/annotations": ">1.15"
},
"prefer-stable": true,
"autoload": {
Expand Down
57 changes: 31 additions & 26 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
];
```

1. Import required config by adding `config/packages/bitbag_sylius_bonus_points_plugin.yaml` file:
1. Import resource in your `config/packages/_sylius.yaml`

```yaml
# config/packages/bitbag_sylius_bonus_points_plugin.yaml
# config/packages/_sylius.yaml
imports:
...
- { resource: "@BitBagSyliusBonusPointsPlugin/Resources/config/config.yml" }
```
Expand All @@ -40,34 +42,37 @@
```php
<?php
declare(strict_types=1);
<?php
declare(strict_types=1);
namespace App\Entity\Order;
use BitBag\SyliusBonusPointsPlugin\Entity\BonusPointsAwareInterface;
use BitBag\SyliusBonusPointsPlugin\Entity\BonusPointsAwareTrait;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Core\Model\Order as BaseOrder;
class Order extends BaseOrder implements BonusPointsAwareInterface
{
use BonusPointsAwareTrait;
}
```
Mapping (XML):
```xml
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>
<entity repository-class="App\Doctrine\ORM\OrderRepository" name="App\Entity\Order\Order" table="sylius_order">
<field name="bonusPoints" type="integer" nullable="true" />
</entity>
</doctrine-mapping>
```
/**
* @ORM\Entity
* @ORM\Table(name="sylius_order")
*/
#[ORM\Entity]
#[ORM\Table(name: 'sylius_order')]
class Order extends BaseOrder implements BonusPointsAwareInterface
{
#[ORM\Column(type: 'integer', nullable: true)]
protected ?int $bonusPoints = null;
public function getBonusPoints(): ?int
{
return $this->bonusPoints;
}
public function setBonusPoints(?int $bonusPoints): void
{
$this->bonusPoints = $bonusPoints;
}
}
1. Customize shop templates to include bonus points. For starter You may want copy to templates directory everything from plugin's tests/Application/templates
Expand Down
11 changes: 8 additions & 3 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php

use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
declare(strict_types=1);

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ECSConfig $config): void {
putenv('ALLOW_BITBAG_OS_HEADER=1');

$config->import('vendor/bitbag/coding-standard/ecs.php');
$config->paths(['src', 'tests']);
};
4 changes: 2 additions & 2 deletions features/admin/adding_bonus_points_strategy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Adding a new bonus points strategy
Background:
Given the store operates on a single channel in "United States"
And I am logged in as an administrator
And the store classifies its products as "T-Shirts", "Watches", "Belts" and "Wallets"
And the store classifies its products as "T-shirts", "Watches", "Belts" and "Wallets"
And the "T-Shirts" taxon has children taxon "Men" and "Women"

@ui @javascript
Expand Down Expand Up @@ -36,4 +36,4 @@ Feature: Adding a new bonus points strategy
And I fill with "10" field "Percent to calculate points"
And I add it
Then I should be notified that the bonus points strategy has been created
And the "second-bitbag-bonus-points-strategy" should appear in the registry
And the "second-bitbag-bonus-points-strategy" should appear in the registry
2 changes: 1 addition & 1 deletion features/admin/managing_bonus_points_strategy.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: Managing a new bonus points strategy
Background:
Given the store operates on a single channel in "United States"
And I am logged in as an administrator
And the store classifies its products as "T-Shirts", "Watches", "Belts" and "Wallets"
And the store classifies its products as "T-shirts", "Watches", "Belts" and "Wallets"
And the "T-Shirts" taxon has children taxon "Men" and "Women"
And there is bonus points strategy with code "bitbag-bonus-points-strategy" and name "BitBag Bonus Points Strategy" with rule "Has taxon" with "Watches" taxon
And the bonus points strategy "bitbag-bonus-points-strategy" admits "2" points per one currency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Feature: Collecting bonus points
And the store allows paying "Offline"
And there is bonus points strategy with code "bitbag-bonus-points-strategy" and name "BitBag Bonus Points Strategy" with rule "Has Taxon" with "Watches" taxon
And the bonus points strategy "bitbag-bonus-points-strategy" admits "2" points per one currency
And the store has a product "BitBag Watch" priced at "$2000.32"
And the store has a product "BitBag Watch" priced at "$2,000.32"
And this product belongs to "Watches"
And there is a customer "Francis Underwood" identified by an email "[email protected]" and a password "whitehouse"
And there is a customer "[email protected]" that placed an order "#00000022"
Expand Down Expand Up @@ -42,4 +42,4 @@ Feature: Collecting bonus points
@ui @javascript
Scenario: Unsuccessfully using of awarded bonus points with "per order price" calculator
When I want to use "0.32" bonus points
Then I should be notified that this value should be natural number, greater than or equal to 1
Then I should be notified that this value should be natural number, greater than or equal to 1
Loading

0 comments on commit 6b3a7ae

Please sign in to comment.