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

Switch to Doctrine/Migrations 3.0 #205

Merged
merged 11 commits into from
Sep 22, 2020
Merged
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
174 changes: 71 additions & 103 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,111 +1,79 @@
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

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/

install:
- composer update --no-interaction --prefer-dist
- (cd tests/Application && yarn install)

before_script:
- (cd tests/Application && bin/console doctrine:database:create -vvv)
- (cd tests/Application && bin/console doctrine:migrations:migrate -n -vvv -q)
- (cd tests/Application && bin/console assets:install -vvv)
- (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

# Download and configure ChromeDriver
- |
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
fi
# Run ChromeDriver
- $SYLIUS_CACHE_DIR/chromedriver > /dev/null 2>&1 &

# 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 &

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

script:
- composer validate --strict
- composer analyse

- vendor/bin/phpunit
- vendor/bin/behat --strict -vvv --no-interaction --tags="~@todo" || vendor/bin/behat --strict -vvv --no-interaction --rerun --tags="~@todo"

after_failure:
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"

-
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

script:
- phpdbg -qrr vendor/bin/phpspec run
- SYLIUS_CACHE_DIR=$HOME/.sylius-cache
- SYLIUS_BUILD_DIR=etc/build

before_install:
- phpenv config-rm xdebug.ini
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- mkdir -p "${SYLIUS_CACHE_DIR}"

install:
- composer install --no-interaction --prefer-dist
- (cd tests/Application && yarn install)

before_script:
- (cd tests/Application && bin/console doctrine:database:create -vvv)
- (cd tests/Application && bin/console doctrine:migrations:migrate -n -vvv -q)
- (cd tests/Application && bin/console assets:install public -vvv)
- (cd tests/Application && bin/console cache:warmup -vvv)
- (cd tests/Application && yarn build)

# Running fixtures to be sure they're not failing
- (cd tests/Application && bin/console sylius:fixtures:load -n --env test)

# Download Symfony CLI
- |
if [ ! -f $SYLIUS_CACHE_DIR/symfony ]; then
wget https://get.symfony.com/cli/installer -O - | bash
mv ~/.symfony/bin/symfony $SYLIUS_CACHE_DIR
fi
php -v | head -n 1 | awk '{ print $2 }' > .php-version

# 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 && $SYLIUS_CACHE_DIR/symfony server:start --port=8080 --dir=public --daemon)

script:
- composer validate --strict
- composer analyse

- vendor/bin/phpunit tests/
- phpdbg -qrr vendor/bin/phpspec run
- vendor/bin/behat --strict -vvv --no-interaction || vendor/bin/behat --strict -vvv --no-interaction --rerun

after_failure:
- vendor/lakion/mink-debug-extension/travis/tools/upload-textfiles "${SYLIUS_BUILD_DIR}/*.log"
16 changes: 14 additions & 2 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ imports:

default:
extensions:
DMore\ChromeExtension\Behat\ServiceContainer\ChromeExtension: ~

Lakion\Behat\MinkDebugExtension:
directory: etc/build
clean_start: false
screenshot: true

Behat\MinkExtension:
files_path: "%paths.base%/vendor/sylius/sylius/src/Sylius/Behat/Resources/fixtures/"
base_url: "http://localhost:8080/"
base_url: "https://127.0.0.1:8080/"
default_session: symfony
javascript_session: chrome
javascript_session: chrome_headless
sessions:
symfony:
symfony: ~
chrome_headless:
chrome:
api_url: http://127.0.0.1:9222
validate_certificate: false
chrome:
selenium2:
browser: chrome
Expand All @@ -30,6 +36,12 @@ default:
- "start-fullscreen"
- "start-maximized"
- "no-sandbox"
extra_capabilities:
acceptSslCerts: true
acceptInsecureCerts: true
unexpectedAlertBehaviour: accept
goog:chromeOptions:
w3c: false # https://github.com/Sylius/Sylius/issues/10561
firefox:
selenium2:
browser: firefox
Expand Down
51 changes: 24 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,38 @@
}
],
"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"
"sylius/sylius": "^1.8",
"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",
"dmore/behat-chrome-extension": "^1.3",
"dmore/chrome-mink-driver": "^2.7",
"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.3",
"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.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"
},
"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
3 changes: 3 additions & 0 deletions 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 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small bc-break

{
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small bc-break

}
22 changes: 21 additions & 1 deletion src/DependencyInjection/SyliusRefundExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

final class SyliusRefundExtension extends Extension
final class SyliusRefundExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
Expand All @@ -21,4 +22,23 @@ public function load(array $config, ContainerBuilder $container): void

$loader->load('services.xml');
}

public function prepend(ContainerBuilder $container): void
{
if (!$container->hasExtension('doctrine_migrations') || !$container->hasExtension('sylius_labs_doctrine_migrations_extra')) {
return;
}

$container->prependExtensionConfig('doctrine_migrations', [
'migrations_paths' => [
'Sylius\RefundPlugin\Migrations' => __DIR__ . '/../Migrations',
],
]);

$container->prependExtensionConfig('sylius_labs_doctrine_migrations_extra', [
'migrations' => [
'Sylius\RefundPlugin\Migrations' => ['Sylius\Bundle\CoreBundle\Migrations'],
],
]);
}
}
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
3 changes: 1 addition & 2 deletions src/Generator/SequentialNumberGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ private function generateNumber(int $index): string

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

if (null !== $sequence) {
return $sequence;
}
Expand Down
Loading