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

Upgrade to Sylius 1.3 & 1.4 and add support for PHP 7.3 #385

Merged
merged 8 commits into from
Feb 8, 2019
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
31 changes: 8 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,12 @@
language: php

php:
- 7.1
- 7.2
- 7.3

env:
- SYLIUS_VERSION=1.1.* SYMFONY_VERSION=3.4.*
- SYLIUS_VERSION=1.2.* SYMFONY_VERSION=3.4.*
- SYLIUS_VERSION=1.2.* SYMFONY_VERSION=4.1.*
- SYLIUS_VERSION=1.3.*@dev SYMFONY_VERSION=3.4.*
- SYLIUS_VERSION=1.3.*@dev SYMFONY_VERSION=4.1.*

matrix:
allow_failures:
-
env: SYLIUS_VERSION=1.3.*@dev SYMFONY_VERSION=3.4.*
-
env: SYLIUS_VERSION=1.3.*@dev SYMFONY_VERSION=4.1.*
exclude:
-
php: 7.1
env: SYLIUS_VERSION=1.3.*@dev SYMFONY_VERSION=3.4.*
-
php: 7.1
env: SYLIUS_VERSION=1.3.*@dev SYMFONY_VERSION=4.1.*
fast_finish: true
- SYLIUS_VERSION=1.3.*
- SYLIUS_VERSION=1.4.*

cache:
directories:
Expand All @@ -34,13 +16,16 @@ before_install:
- phpenv config-rm xdebug.ini || true
- echo "memory_limit=4096M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini

- cp tests/Application/.env.test.dist tests/Application/.env.test
- set -a && source tests/Application/.env.test && set +a

install:
- composer require sylius/sylius:${SYLIUS_VERSION} --no-interaction --no-update
- composer require symfony/symfony:${SYMFONY_VERSION} --no-interaction --no-update
- composer update --no-interaction --prefer-dist

before_script:
- (cd tests/Application && bin/console doctrine:schema:create --env=test)
- (cd tests/Application && bin/console doctrine:database:create --env=test -vvv)
- (cd tests/Application && bin/console doctrine:schema:create --env=test -vvv)

script:
- composer validate --strict
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"description": "Shop API for Sylius E-Commerce.",
"license": "MIT",
"require": {
"php": "^7.1",
"php": "^7.2",

"sylius/sylius": "^1.1",
"sylius/sylius": "^1.3",
"league/tactician-bundle": "^1.1",
"league/tactician-doctrine": "^1.1"
},
Expand All @@ -21,6 +21,7 @@
"phpunit/phpunit": "^6.5",
"sylius-labs/coding-standard": "^2.0",
"symfony/debug-bundle": "^3.4|^4.1",
"symfony/dotenv": "^3.4|^4.1",
"symfony/web-profiler-bundle": "^3.4|^4.1",
"symfony/web-server-bundle": "^3.4|^4.1"
},
Expand All @@ -41,8 +42,7 @@
"autoload-dev": {
"psr-4": {
"Tests\\Sylius\\ShopApiPlugin\\": "tests/"
},
"classmap": ["tests/Application/app/AppKernel.php"]
}
},
"suggest": {
"nelmio/cors-bundle": "allows you to send Cross-Origin Ajax API Request"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</testsuites>

<php>
<server name="KERNEL_CLASS" value="AppKernel" />
<server name="KERNEL_CLASS" value="Tests\Sylius\ShopApiPlugin\Application\Kernel" />
<server name="IS_DOCTRINE_ORM_SUPPORTED" value="true" />
<server name="ESCAPE_JSON" value="true" />
</php>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ private function getChannel(string $channelCode): ChannelInterface
private function findByTaxon(TaxonInterface $taxon, ChannelInterface $channel, PaginatorDetails $paginatorDetails, string $localeCode): PageView
{
$queryBuilder = $this->productRepository->createShopListQueryBuilder($channel, $taxon, $localeCode);
$queryBuilder->addSelect('productTaxon');
$queryBuilder->addOrderBy('productTaxon.position');

$pagerfanta = new Pagerfanta(new DoctrineORMAdapter($queryBuilder));
Expand Down
23 changes: 23 additions & 0 deletions tests/Application/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_DEBUG=1
APP_SECRET=EDITME
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###
23 changes: 23 additions & 0 deletions tests/Application/.env.prod.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=prod
APP_DEBUG=0
APP_SECRET=EDITME
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=smtp://localhost
###< symfony/swiftmailer-bundle ###
23 changes: 23 additions & 0 deletions tests/Application/.env.test.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This file is a "template" of which env vars needs to be defined in your configuration or in an .env file
# Set variables here that may be different on each deployment target of the app, e.g. development, staging, production.
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration

###> symfony/framework-bundle ###
APP_ENV=test
APP_DEBUG=1
APP_SECRET=EDITME
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For a sqlite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Set "serverVersion" to your server version to avoid edge-case exceptions and extra database calls
DATABASE_URL=mysql://root@127.0.0.1/sylius_%kernel.environment%?serverVersion=5.5
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:password@localhost"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###
23 changes: 18 additions & 5 deletions tests/Application/.gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
/node_modules/
/var/*
!/var/.gitignore

/var/
!/var/.gitkeep
/public/assets
/public/bundles
/public/css
/public/js
/public/media/*
!/public/media/image/
/public/media/image/*
!/public/media/image/.gitignore

!/web/app_test.php
/web/
/vendor
/node_modules

/.env
/.env.prod
/.env.staging
/.env.test
/.env.test_cached
106 changes: 106 additions & 0 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

declare(strict_types=1);

namespace Tests\Sylius\ShopApiPlugin\Application;

use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\Config\FileLocator;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Webmozart\Assert\Assert;

final class Kernel extends BaseKernel
{
use MicroKernelTrait;

private const CONFIG_EXTS = '.{php,xml,yaml,yml}';

public function getCacheDir(): string
{
return $this->getProjectDir() . '/var/cache/' . $this->environment;
}

public function getLogDir(): string
{
return $this->getProjectDir() . '/var/log';
}

public function registerBundles(): iterable
{
$contents = require $this->getProjectDir() . '/config/bundles.php';
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
}

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
$container->setParameter('container.dumper.inline_class_loader', true);
$confDir = $this->getProjectDir() . '/config';

$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{services}' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{services}_' . $this->environment . self::CONFIG_EXTS, 'glob');
}

protected function configureRoutes(RouteCollectionBuilder $routes): void
{
$confDir = $this->getProjectDir() . '/config';

$routes->import($confDir . '/{routes}/*' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob');
$routes->import($confDir . '/{routes}' . self::CONFIG_EXTS, '/', 'glob');
}

protected function getContainerBaseClass(): string
{
if ($this->isTestEnvironment()) {
return MockerContainer::class;
}

return parent::getContainerBaseClass();
}

protected function getContainerLoader(ContainerInterface $container): LoaderInterface
{
/** @var ContainerBuilder $container */
Assert::isInstanceOf($container, ContainerBuilder::class);

$locator = new FileLocator($this, $this->getRootDir() . '/Resources');
$resolver = new LoaderResolver(array(
new XmlFileLoader($container, $locator),
new YamlFileLoader($container, $locator),
new IniFileLoader($container, $locator),
new PhpFileLoader($container, $locator),
new GlobFileLoader($container, $locator),
new DirectoryLoader($container, $locator),
new ClosureLoader($container),
));

return new DelegatingLoader($resolver);
}

private function isTestEnvironment(): bool
{
return 0 === strpos($this->getEnvironment(), 'test');
}
}
38 changes: 0 additions & 38 deletions tests/Application/app/AppKernel.php

This file was deleted.

Loading