Skip to content

Commit

Permalink
Add Sylius 1.13 support
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Jun 3, 2024
1 parent dbf4c04 commit 42e70b9
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 64 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.0", "8.1"]
php: ["8.1", "8.2", "8.3"]
symfony: ["5.4.*", "^6.0"]
sylius: ["^1.12"]
sylius: ["^1.12.0", "^1.13.1"]
node: ["18.x"]
mysql: ["5.7", "8.0"]
mysql: ["8.0"]

env:
APP_ENV: test
Expand All @@ -46,7 +46,7 @@ jobs:

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

Expand Down Expand Up @@ -84,7 +84,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 Down Expand Up @@ -121,7 +121,7 @@ jobs:

-
name: Cache Yarn
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ matrix.node }}-yarn-${{ hashFiles('**/package.json **/yarn.lock') }}
Expand Down
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
],
"license": "MIT",
"require": {
"php": "^8.0",
"php": "^8.1",
"sandwich/vies-bundle": "^2.1",
"sylius/sylius": "^1.12.9",
"sylius/mailer-bundle": "^1.8 || ^2.0",
"sylius/sylius": "^1.12",
"symfony/webpack-encore-bundle": "^1.15",
"webmozart/assert": "^1.9"
},
"require-dev": {
"behat/behat": "^3.6.1",
"behat/mink-selenium2-driver": "^1.4",
"behat/mink-selenium2-driver": "^1.6",
"dbrekelmans/bdi": "^1.1",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"friends-of-behat/mink": "^1.8",
Expand All @@ -34,16 +34,19 @@
"phpstan/phpstan-doctrine": "1.3.16",
"phpstan/phpstan-strict-rules": "^1.3.0",
"phpstan/phpstan-webmozart-assert": "^1.2.0",
"phpunit/phpunit": "^9.5",
"phpunit/phpunit": "^9.6 || ^10.5",
"polishsymfonycommunity/symfony-mocker-container": "^1.0",
"rector/rector": "^0.15.0",
"robertfausk/behat-panther-extension": "^1.1",
"sylius-labs/coding-standard": "^4.2",
"sylius-labs/suite-tags-extension": "^0.2",
"symfony/browser-kit": "^5.4 || ^6.0",
"symfony/debug-bundle": "^5.4 || ^6.0",
"symfony/dotenv": "^5.4 || ^6.0",
"symfony/flex": "^2.2.2",
"symfony/intl": "^5.4 || ^6.0",
"symfony/web-profiler-bundle": "^5.4 || ^6.0",
"vimeo/psalm": "4.27.0"
"vimeo/psalm": "^4.27"
},
"config": {
"sort-packages": true,
Expand Down
7 changes: 5 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
parameters:
level: max
reportUnmatchedIgnoredErrors: false
checkMissingIterableValueType: false
paths:
- src
- tests/Behat

excludes_analyse:
excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'

Expand All @@ -15,4 +14,8 @@ parameters:
- 'tests/Application/src/**.php'

ignoreErrors:
-
identifier: missingType.iterableValue
-
identifier: missingType.generics
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
7 changes: 6 additions & 1 deletion tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return [
$bundles = [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
Expand Down Expand Up @@ -60,3 +60,8 @@
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
League\FlysystemBundle\FlysystemBundle::class => ['all' => true],
];
if (class_exists(Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class)) {
$bundles[Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class] = ['all' => true];
}

return $bundles;
38 changes: 19 additions & 19 deletions tests/Behat/Context/Transform/AddressContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ final class AddressContext implements Context
private Generator $fakerGenerator;

public function __construct(
private ExampleFactoryInterface $exampleAddressFactory,
private CountryNameConverterInterface $countryNameConverter
private readonly ExampleFactoryInterface $exampleAddressFactory,
private readonly CountryNameConverterInterface $countryNameConverter
) {
$this->fakerGenerator = Factory::create();
}
Expand All @@ -28,11 +28,11 @@ public function __construct(
* @Transform /^address for the individual "([^"]+)" - "([^"]+)", "([^"]+)", "([^"]+)" - "([^"]+)"$/
*/
public function createNewIndividualAddressWith(
$customerName,
$city,
$street,
$postcode,
$countryName
string $customerName,
string $city,
string $street,
string $postcode,
string $countryName
): AddressInterface {
[$firstName, $lastName] = explode(' ', $customerName);

Expand All @@ -57,12 +57,12 @@ public function createNewIndividualAddressWith(
* @Transform /^address for the company "([^"]*)" - "([^"]*)" - "([^"]*)", "([^"]*)", "([^"]*)" - "([^"]*)"$/
*/
public function createNewCompanyAddressWith(
$company,
$customerName,
$street,
$postcode,
$city,
$countryName
string $company,
string $customerName,
string $street,
string $postcode,
string $city,
string $countryName
): AddressInterface {
[$firstName, $lastName] = explode(' ', $customerName);

Expand Down Expand Up @@ -90,7 +90,7 @@ public function createNewCompanyAddressWith(
*/
public function createNewValidItalianIndividualBillingAddress()
{
/** @var AddressInterface&ItalianInvoiceableAddressInterface $address */
/** @var AddressInterface|(AddressInterface&ItalianInvoiceableAddressInterface) $address */
$address = $this->exampleAddressFactory->create(['country_code' => 'IT', 'customer' => null]);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$address->setBillingRecipientType(ItalianInvoiceableAddressInterface::BILLING_RECIPIENT_TYPE_INDIVIDUAL);
Expand All @@ -105,7 +105,7 @@ public function createNewValidItalianIndividualBillingAddress()
*/
public function createNewValidItalianCompanyBillingAddress()
{
/** @var AddressInterface&ItalianInvoiceableAddressInterface $address */
/** @var AddressInterface|(AddressInterface&ItalianInvoiceableAddressInterface) $address */
$address = $this->exampleAddressFactory->create(['country_code' => 'IT', 'customer' => null]);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$address->setBillingRecipientType(ItalianInvoiceableAddressInterface::BILLING_RECIPIENT_TYPE_COMPANY);
Expand All @@ -125,7 +125,7 @@ public function createNewValidItalianCompanyBillingAddress()
*/
public function createNewValidGermanIndividualBillingAddress()
{
/** @var AddressInterface&ItalianInvoiceableAddressInterface $address */
/** @var AddressInterface|(AddressInterface&ItalianInvoiceableAddressInterface) $address */
$address = $this->exampleAddressFactory->create(['country_code' => 'DE', 'customer' => null]);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$address->setBillingRecipientType(ItalianInvoiceableAddressInterface::BILLING_RECIPIENT_TYPE_INDIVIDUAL);
Expand All @@ -138,7 +138,7 @@ public function createNewValidGermanIndividualBillingAddress()
*/
public function createNewValidGermanCompanyBillingAddress()
{
/** @var AddressInterface&ItalianInvoiceableAddressInterface $address */
/** @var AddressInterface|(AddressInterface&ItalianInvoiceableAddressInterface) $address */
$address = $this->exampleAddressFactory->create(['country_code' => 'DE', 'customer' => null]);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$address->setBillingRecipientType(ItalianInvoiceableAddressInterface::BILLING_RECIPIENT_TYPE_COMPANY);
Expand All @@ -155,7 +155,7 @@ public function createNewValidGermanCompanyBillingAddress()
*/
public function createNewValidUSIndividualBillingAddress()
{
/** @var AddressInterface&ItalianInvoiceableAddressInterface $address */
/** @var AddressInterface|(AddressInterface&ItalianInvoiceableAddressInterface) $address */
$address = $this->exampleAddressFactory->create(['country_code' => 'US', 'customer' => null]);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$address->setBillingRecipientType(ItalianInvoiceableAddressInterface::BILLING_RECIPIENT_TYPE_INDIVIDUAL);
Expand All @@ -169,7 +169,7 @@ public function createNewValidUSIndividualBillingAddress()
*/
public function createNewValidUSCompanyBillingAddress()
{
/** @var AddressInterface&ItalianInvoiceableAddressInterface $address */
/** @var AddressInterface|(AddressInterface&ItalianInvoiceableAddressInterface) $address */
$address = $this->exampleAddressFactory->create(['country_code' => 'US', 'customer' => null]);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$address->setBillingRecipientType(ItalianInvoiceableAddressInterface::BILLING_RECIPIENT_TYPE_COMPANY);
Expand Down
34 changes: 12 additions & 22 deletions tests/Behat/Context/Ui/Shop/Checkout/CheckoutAddressingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ final class CheckoutAddressingContext implements Context
private Generator $fakerGenerator;

public function __construct(
private AddressPageInterface $addressPage,
private SharedStorageInterface $sharedStorage
private readonly AddressPageInterface $addressPage,
private readonly SharedStorageInterface $sharedStorage
) {
$this->fakerGenerator = Factory::create();
}
Expand All @@ -46,7 +46,7 @@ public function iSpecifyTheBillingAddressForTheIndividual(AddressInterface $addr
*/
public function iSpecifyAValidIndividualTaxCode(): void
{
$this->addressPage->specifyBillingTaxCode($this->fakerGenerator->ssn);
$this->addressPage->specifyBillingTaxCode($this->fakerGenerator->ssn); //@phpstan-ignore-line
}

/**
Expand Down Expand Up @@ -291,10 +291,10 @@ public function iDoNotSpecifyTheBillingRecipientTypeInTheBillingAddress(): void
public function iSpecifyTheSameItalianInvoiceableInformationOfTheAddressThatIHaveInMyAddressBook(AddressInterface $address): void
{
/** @var ItalianInvoiceableAddressInterface $address */
$this->addressPage->specifyBillingTaxCode($address->getTaxCode());
$this->addressPage->specifyBillingVatNumber($address->getVatNumber());
$this->addressPage->specifyBillingSdiCode($address->getSdiCode());
$this->addressPage->specifyBillingPecAddress($address->getPecAddress());
$this->addressPage->specifyBillingTaxCode((string) $address->getTaxCode());
$this->addressPage->specifyBillingVatNumber((string) $address->getVatNumber());
$this->addressPage->specifyBillingSdiCode((string) $address->getSdiCode());
$this->addressPage->specifyBillingPecAddress((string) $address->getPecAddress());
}

/**
Expand Down Expand Up @@ -329,10 +329,8 @@ public function addressShouldBeFilledAsBillingAddress(AddressInterface $address)
*/
public function iSpecifyAValidItalianIndividualBillingAddress($address): void
{
Assert::isInstanceOf($address, AddressInterface::class);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$this->addressPage->specifyBillingAddress($address);
$this->addressPage->specifyBillingTaxCode($address->getTaxCode());
$this->addressPage->specifyBillingTaxCode((string) $address->getTaxCode());
}
/**
* @When /^I specify a (valid italian company billing address)$/
Expand All @@ -341,12 +339,10 @@ public function iSpecifyAValidItalianIndividualBillingAddress($address): void
*/
public function iSpecifyAValidItalianCompanyBillingAddress($address): void
{
Assert::isInstanceOf($address, AddressInterface::class);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$this->addressPage->specifyBillingAddress($address);
$this->addressPage->specifyBillingVatNumber($address->getVatNumber());
$this->addressPage->specifyBillingTaxCode($address->getTaxCode());
$this->addressPage->specifyBillingSdiCode($address->getSdiCode());
$this->addressPage->specifyBillingVatNumber((string) $address->getVatNumber());
$this->addressPage->specifyBillingTaxCode((string) $address->getTaxCode());
$this->addressPage->specifyBillingSdiCode((string) $address->getSdiCode());
}
/**
* @Given /^I specify a (valid german individual billing address)$/
Expand All @@ -355,8 +351,6 @@ public function iSpecifyAValidItalianCompanyBillingAddress($address): void
*/
public function iSpecifyAValidGermanIndividualBillingAddress($address): void
{
Assert::isInstanceOf($address, AddressInterface::class);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$this->addressPage->specifyBillingAddress($address);
}
/**
Expand All @@ -366,10 +360,8 @@ public function iSpecifyAValidGermanIndividualBillingAddress($address): void
*/
public function iSpecifyAValidGermanCompanyBillingAddress($address): void
{
Assert::isInstanceOf($address, AddressInterface::class);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$this->addressPage->specifyBillingAddress($address);
$this->addressPage->specifyBillingVatNumber($address->getVatNumber());
$this->addressPage->specifyBillingVatNumber((string) $address->getVatNumber());
}

/**
Expand All @@ -380,8 +372,6 @@ public function iSpecifyAValidGermanCompanyBillingAddress($address): void
*/
public function iSpecifyAValidUSlBillingAddress($address): void
{
Assert::isInstanceOf($address, AddressInterface::class);
Assert::isInstanceOf($address, ItalianInvoiceableAddressInterface::class);
$this->addressPage->specifyBillingAddress($address);
}
}
23 changes: 15 additions & 8 deletions tests/Behat/Page/Shop/Checkout/AddressPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class AddressPage extends BaseAddressPage implements AddressPageInterface
{
/**
* @param AddressInterface&ItalianInvoiceableAddressInterface $billingAddress
* @param AddressInterface|(AddressInterface&ItalianInvoiceableAddressInterface) $billingAddress
*/
public function specifyBillingAddress(AddressInterface $billingAddress): void
{
Expand Down Expand Up @@ -67,9 +67,9 @@ protected function getDefinedElements(): array
);
}

private function waitForElement(int $timeout, string $elementName): bool
private function waitForElement(int $timeout, string $elementName): void
{
return $this->getDocument()->waitFor($timeout, function () use ($elementName) {
$this->getDocument()->waitFor($timeout, function () use ($elementName) {
return $this->hasElement($elementName);
});
}
Expand All @@ -85,27 +85,34 @@ public function isWithoutAnyInvoicingRelatedFieldInShippingAddress(): bool

public function getPreFilledBillingRecipientType(): string
{
return $this->getElement('billing_billing_recipient_type')->getValue();
return $this->getStringValue('billing_billing_recipient_type');
}

public function getPreFilledBillingTaxCode(): string
{
return $this->getElement('billing_tax_code')->getValue();
return $this->getStringValue('billing_tax_code');
}

public function getPreFilledBillingVatNumber(): string
{
return $this->getElement('billing_vat_number')->getValue();
return $this->getStringValue('billing_vat_number');
}

public function getPreFilledBillingSdiCode(): string
{
return $this->getElement('billing_sdi_code')->getValue();
return $this->getStringValue('billing_sdi_code');
}

public function getPreFilledBillingPecAddress(): string
{
return $this->getElement('billing_pec_address')->getValue();
return $this->getStringValue('billing_pec_address');
}

private function getStringValue(string $element): string
{
$value = $this->getElement($element)->getValue();
Assert::string($value);

return $value;
}
}

0 comments on commit 42e70b9

Please sign in to comment.