diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee9a297f..acc7ba25 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4] + php: [7.4, 8.0] symfony: [^4.4, ^5.2] include: @@ -47,13 +47,13 @@ jobs: name: Require sylius/currency-bundle if: matrix.currency-bundle != '' run: | - composer require "sylius/currency-bundle:${{ matrix.currency-bundle }}" + composer require "sylius/currency-bundle:${{ matrix.currency-bundle }}" --no-update --no-scripts - name: Install dependencies run: | - composer update ${{ matrix.composer-flags }} --no-scripts - (cd src/Component && composer update ${{ matrix.composer-flags }} --no-scripts) + composer update ${{ matrix.php == '8.0' && '--ignore-platform-req=php' || '' }} --no-scripts + (cd src/Component && composer update ${{ matrix.php == '8.0' && '--ignore-platform-req=php' || '' }} --no-scripts) - name: Prepare test application diff --git a/composer.json b/composer.json index 1f69f60b..a5a73e19 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ } ], "require": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0", "sylius/registry": "^1.5", "symfony/config": "^4.4 || ^5.2", @@ -65,7 +65,7 @@ "phpstan/phpstan-webmozart-assert": "0.12.12", "phpunit/phpunit": "^9.5", "sylius-labs/coding-standard": "^3.0", - "sylius/resource-bundle": "^1.7", + "sylius/resource-bundle": "^1.8", "symfony/console": "^4.4 || ^5.2", "symfony/dotenv": "^4.4 || ^5.2", "symfony/polyfill-mbstring": "<1.22.0 || >1.22.0", diff --git a/phpspec.yml.dist b/phpspec.yml.dist index 53455daa..6055b70b 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -12,3 +12,5 @@ suites: extensions: Akeneo\SkipExampleExtension: ~ + +bootstrap: phpspec/bootstrap.php diff --git a/phpspec/bootstrap.php b/phpspec/bootstrap.php new file mode 100644 index 00000000..7b73a07a --- /dev/null +++ b/phpspec/bootstrap.php @@ -0,0 +1,6 @@ +beConstructedWith($queryBuilder, $expressionBuilder); - } - function it_implements_data_source(): void - { $this->shouldImplement(DataSourceInterface::class); } function it_should_restrict_with_or_condition( + QueryBuilder $queryBuilder, + ExpressionBuilderInterface $expressionBuilder, Comparison $comparison, Value $value, - QueryBuilder $queryBuilder, ConstraintOrx $constraint, ConstraintComparison $comparisonConstraint ): void { + $this->beConstructedWith($queryBuilder, $expressionBuilder); + $queryBuilder->orWhere()->willReturn($constraint); $value->getValue()->willReturn('value'); $comparison->getValue()->willReturn($value); @@ -65,16 +68,23 @@ function it_should_restrict_with_or_condition( } function it_should_throw_an_exception_if_an_unknown_condition_is_passed( + QueryBuilder $queryBuilder, + ExpressionBuilderInterface $expressionBuilder, Comparison $comparison ): void { + $this->beConstructedWith($queryBuilder, $expressionBuilder); + $this->shouldThrow( new \RuntimeException('Unknown restrict condition "foo"') )->during('restrict', [$comparison, 'foo']); } function it_should_return_the_expression_builder( + QueryBuilder $queryBuilder, ExpressionBuilderInterface $expressionBuilder ): void { + $this->beConstructedWith($queryBuilder, $expressionBuilder); + $this->getExpressionBuilder()->shouldReturn($expressionBuilder); } @@ -83,6 +93,8 @@ function it_should_get_the_data( ExpressionBuilderInterface $expressionBuilder, Query $query ): void { + $this->beConstructedWith($queryBuilder, $expressionBuilder); + $expressionBuilder->getOrderBys()->willReturn([]); $queryBuilder->orderBy()->willReturn(null); @@ -101,6 +113,8 @@ function it_should_set_the_order_on_the_query_builder( OrderBy $orderBy, Ordering $ordering ): void { + $this->beConstructedWith($queryBuilder, $expressionBuilder); + $expressionBuilder->getOrderBys()->willReturn([ 'foo' => 'asc', 'bar' => 'desc', @@ -126,6 +140,8 @@ function it_should_set_the_order_on_the_query_builder_as_fields_only( OrderBy $orderBy, Ordering $ordering ): void { + $this->beConstructedWith($queryBuilder, $expressionBuilder); + $expressionBuilder->getOrderBys()->willReturn([ 'foo', 'bar', diff --git a/src/Component/composer.json b/src/Component/composer.json index 1b6915ff..561c4e55 100644 --- a/src/Component/composer.json +++ b/src/Component/composer.json @@ -28,7 +28,7 @@ } ], "require": { - "php": "^7.4", + "php": "^7.4 || ^8.0", "sylius-labs/polyfill-symfony-event-dispatcher": "^1.0", "sylius/registry": "^1.5", "symfony/deprecation-contracts": "^2.2", diff --git a/src/Component/phpspec.yml.dist b/src/Component/phpspec.yml.dist index 7760865f..dfb0ce53 100644 --- a/src/Component/phpspec.yml.dist +++ b/src/Component/phpspec.yml.dist @@ -3,3 +3,5 @@ suites: namespace: Sylius\Component\Grid psr4_prefix: Sylius\Component\Grid src_path: . + +bootstrap: phpspec/bootstrap.php diff --git a/src/Component/phpspec/bootstrap.php b/src/Component/phpspec/bootstrap.php new file mode 100644 index 00000000..7b73a07a --- /dev/null +++ b/src/Component/phpspec/bootstrap.php @@ -0,0 +1,6 @@ +