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

Fix the build, add support for PHP 7.4 #219

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
/node_modules/
/composer.lock

/.phpunit.result.cache

/etc/build/*
!/etc/build/.gitkeep

/tests/Application/yarn.lock

.env.test
/.env.test

phpspec.yml
/phpspec.yml
83 changes: 37 additions & 46 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
language: php

dist: trusty
os: linux

dist: bionic

php:
- 7.2
- '7.3'
- '7.4'

services:
- mysql

addons:
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
chrome: stable

cache:
yarn: true
directories:
- ~/.composer/cache/files
- $SYLIUS_CACHE_DIR

env:
global:
- APP_ENV=test
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
- SYLIUS_BUILD_DIR=etc/build

jobs:
include:
- &test
stage: test
name: "Build"

sudo: false

env: SYLIUS_CACHE_DIR=$HOME/.sylius-cache SYLIUS_BUILD_DIR=etc/build

cache:
yarn: true
directories:
- ~/.composer/cache/files
- $SYLIUS_CACHE_DIR

services:
- memcached
- mysql

before_install:
- phpenv config-rm xdebug.ini || true

- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

- mkdir -p tests/Application/public/media/image/
- cp migrations/* tests/Application/src/Migrations/
Expand All @@ -49,35 +56,25 @@ jobs:
- (cd tests/Application && bin/console cache:warmup -vvv)
- (cd tests/Application && yarn build)

# Configure display
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1680x1050x16
- export DISPLAY=:99

# Download Symfony command
- wget https://get.symfony.com/cli/installer -O - | bash
# Running fixtures to be sure they're not failing
- (cd tests/Application && bin/console sylius:fixtures:load -n --env test)

# Download and configure ChromeDriver
# Download Symfony CLI
- |
if [ ! -f $SYLIUS_CACHE_DIR/chromedriver ] || [ "$($SYLIUS_CACHE_DIR/chromedriver --version | grep -c 2.34)" = "0" ]; then
curl http://chromedriver.storage.googleapis.com/2.34/chromedriver_linux64.zip > chromedriver.zip
unzip chromedriver.zip
chmod +x chromedriver
mv chromedriver $SYLIUS_CACHE_DIR
if [ ! -f $SYLIUS_CACHE_DIR/symfony ]; then
wget https://get.symfony.com/cli/installer -O - | bash
mv ~/.symfony/bin/symfony $SYLIUS_CACHE_DIR
fi
# Run ChromeDriver
- $SYLIUS_CACHE_DIR/chromedriver > /dev/null 2>&1 &
php -v | head -n 1 | awk '{ print $2 }' > .php-version

# Download and configure Selenium
- |
if [ ! -f $SYLIUS_CACHE_DIR/selenium.jar ] || [ "$(java -jar $SYLIUS_CACHE_DIR/selenium.jar --version | grep -c 3.4.0)" = "0" ]; then
curl http://selenium-release.storage.googleapis.com/3.4/selenium-server-standalone-3.4.0.jar > selenium.jar
mv selenium.jar $SYLIUS_CACHE_DIR
fi
# Run Selenium
- java -Dwebdriver.chrome.driver=$SYLIUS_CACHE_DIR/chromedriver -jar $SYLIUS_CACHE_DIR/selenium.jar > /dev/null 2>&1 &
# Install certificates
- $SYLIUS_CACHE_DIR/symfony server:ca:install

# Run Chrome Headless
- google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &

# Run webserver
- (cd tests/Application && /home/travis/.symfony/bin/symfony server:start --port=8080 --dir=public --allow-http --no-tls --force-php-discovery --daemon)
- (cd tests/Application && $SYLIUS_CACHE_DIR/symfony server:start --port=8080 --dir=public --daemon)

script:
- composer validate --strict
Expand All @@ -93,16 +90,10 @@ jobs:
stage: test
name: "PHPSpec (with code coverage)"

sudo: false

services:
- memcached

before_install:
- phpenv config-rm xdebug.ini || true

- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

install:
- composer update --no-interaction --prefer-dist
Expand Down
48 changes: 22 additions & 26 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,37 @@
}
],
"require": {
"php": "^7.2",
"knplabs/knp-snappy-bundle": "^1.5",
"php": "^7.3",
"knplabs/knp-snappy-bundle": "^1.7",
"myclabs/php-enum": "^1.7",
"sylius/resource-bundle": "^1.6",
"sylius/sylius": "^1.5",
"symfony/messenger": "^4.3"
"symfony/messenger": "^4.4"
},
"require-dev": {
"behat/behat": "^3.4",
"behat/mink": "^1.7@dev",
"behat/behat": "^3.6",
"behat/mink": "^1.8",
"behat/mink-browserkit-driver": "^1.3",
"behat/mink-extension": "^2.2",
"behat/mink-selenium2-driver": "^1.3",
"behat/mink-extension": "^2.3",
"behat/mink-selenium2-driver": "^1.4",
"friends-of-behat/page-object-extension": "^0.3",
"friends-of-behat/suite-settings-extension": "^1.0",
"friends-of-behat/symfony-extension": "^2.0",
"friends-of-behat/variadic-extension": "^1.1",
"friends-of-behat/symfony-extension": "^2.1",
"friends-of-behat/variadic-extension": "^1.3",
"friends-of-phpspec/phpspec-code-coverage": "^4.2",
"lakion/mink-debug-extension": "^1.2.3",
"leanphp/phpspec-code-coverage": "^4.2",
"phpspec/phpspec": "^4.0",
"phpstan/phpstan-shim": "^0.11",
"phpstan/phpstan-webmozart-assert": "^0.11",
"phpunit/phpunit": "^6.5",
"sylius-labs/coding-standard": "^2.0",
"symfony/browser-kit": "^4.3",
"symfony/debug-bundle": "^4.3",
"symfony/dotenv": "^4.2",
"symfony/framework-bundle": "^4.3",
"symfony/intl": "^4.3",
"symfony/web-profiler-bundle": "^4.3",
"symfony/web-server-bundle": "^4.3"
},
"conflict": {
"symfony/doctrine-bridge": "4.3.0",
"symfony/framework-bundle": "4.3.0"
"phpspec/phpspec": "^6.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-webmozart-assert": "^0.12",
"phpunit/phpunit": "^8.5",
"sylius-labs/coding-standard": "^3.1",
"symfony/browser-kit": "^4.4",
"symfony/debug-bundle": "^4.4",
"symfony/dotenv": "^4.4",
"symfony/framework-bundle": "^4.4",
"symfony/intl": "^4.4",
"symfony/web-profiler-bundle": "^4.4",
"symfony/web-server-bundle": "^4.4"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpspec.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ suites:
psr4_prefix: Sylius\RefundPlugin

extensions:
LeanPHP\PhpSpec\CodeCoverage\CodeCoverageExtension:
FriendsOfPhpSpec\PhpSpec\CodeCoverage\CodeCoverageExtension:
blacklist:
- src/Action #controllers should not be unit tests, as they only translates request to response (with some operations in the meantime)
- src/DependencyInjection #configuration
Expand Down
6 changes: 5 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ includes:
- vendor/phpstan/phpstan-webmozart-assert/extension.neon

parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

excludes_analyse:
# Makes PHPStan crash
- 'src/DependencyInjection/Configuration.php'
Expand All @@ -11,4 +14,5 @@ parameters:
- 'tests/Application/src/**.php'

ignoreErrors:
- '/Parameter #1 $configuration of method Symfony\Component\DependencyInjection\Extension\Extension::processConfiguration() expects Symfony\Component\Config\Definition\ConfigurationInterface, Symfony\Component\Config\Definition\ConfigurationInterface|null given./'
- '/Parameter #1 \$configuration of method Symfony\\Component\\DependencyInjection\\Extension\\Extension::processConfiguration\(\) expects Symfony\\Component\\Config\\Definition\\ConfigurationInterface, Symfony\\Component\\Config\\Definition\\ConfigurationInterface\|null given\./'
- '/expects string, string\|null given\.$/'
7 changes: 6 additions & 1 deletion src/Action/Admin/OrderRefundsListAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig\Environment;
use Webmozart\Assert\Assert;

final class OrderRefundsListAction
{
Expand Down Expand Up @@ -64,10 +65,14 @@ public function __invoke(Request $request): Response
return $this->redirectToReferer($order, 'sylius_refund.order_should_be_paid');
}

$channel = $order->getChannel();

Assert::notNull($channel);

return new Response(
$this->twig->render('@SyliusRefundPlugin/orderRefunds.html.twig', [
'order' => $order,
'payment_methods' => $this->refundPaymentMethodsProvider->findForChannel($order->getChannel()),
'payment_methods' => $this->refundPaymentMethodsProvider->findForChannel($channel),
])
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Calculator/UnitRefundTotalCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(RemainingTotalProviderInterface $remainingTotalProvi
$this->remainingTotalProvider = $remainingTotalProvider;
}

public function calculateForUnitWithIdAndType(int $id, RefundType $refundType, ?float $amount = null)
public function calculateForUnitWithIdAndType(int $id, RefundType $refundType, ?float $amount = null): int
{
if ($amount !== null) {
return (int) round($amount * 100);
Expand Down
2 changes: 1 addition & 1 deletion src/Calculator/UnitRefundTotalCalculatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

interface UnitRefundTotalCalculatorInterface
{
public function calculateForUnitWithIdAndType(int $id, RefundType $refundType, ?float $amount = null);
public function calculateForUnitWithIdAndType(int $id, RefundType $refundType, ?float $amount = null): int;
}
2 changes: 1 addition & 1 deletion src/Form/Type/ChannelFilterType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(ChannelRepositoryInterface $channelRepository)
$this->channelRepository = $channelRepository;
}

public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('channel', ChoiceType::class, [
'choices' => $this->getChannelsList(),
Expand Down
6 changes: 5 additions & 1 deletion src/Generator/CreditMemoGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public function generate(
$this->shipmentLineItemsConverter->convert($shipments)
);

$billingAddress = $order->getBillingAddress();

Assert::notNull($billingAddress);

return new CreditMemo(
$this->uuidCreditMemoIdentifierGenerator->generate(),
$this->creditMemoNumberGenerator->generate(),
Expand All @@ -86,7 +90,7 @@ public function generate(
$this->taxItemsGenerator->generate($lineItems),
$comment,
$this->currentDateTimeImmutableProvider->now(),
$this->getFromAddress($order->getBillingAddress()),
$this->getFromAddress($billingAddress),
$this->getToAddress($channel->getShopBillingData())
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/SequentialNumberGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private function generateNumber(int $index): string

private function getSequence(): CreditMemoSequenceInterface
{
/** @var CreditMemoSequenceInterface $sequence */
/** @var CreditMemoSequenceInterface|null $sequence */
$sequence = $this->sequenceRepository->findOneBy([]);

if (null !== $sequence) {
Expand Down