Skip to content

Commit

Permalink
Feature migration sf5 (#109)
Browse files Browse the repository at this point in the history
* Adding support sf5
* Removing support php5
* clean test
  • Loading branch information
stood committed Oct 18, 2020
1 parent 6cff486 commit 50cb32a
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 97 deletions.
60 changes: 31 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
language: php

sudo: false
addons:
chrome: stable

php:
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "nightly"
sudo: false

env:
matrix:
- SYMFONY_VERSION=2
- SYMFONY_VERSION=3
- SYMFONY_VERSION=4
global:
- COMPOSER_MEMORY_LIMIT=-1

matrix:
allow_failures:
- php: nightly
fast_finish: true
include:
- php: 7.1
env: COMPOSER_FLAGS="--prefer-lowest"
- php: 7.2
- php: 7.3
- php: 7.3
env: SYMFONY_REQUIRE="3.4.*"
- php: 7.3
env: SYMFONY_REQUIRE="4.3.*"
- php: 7.3
env: SYMFONY_REQUIRE="4.4.*"
- php: 7.4
env: SYMFONY_REQUIRE="5.*"

cache:
directories:
Expand All @@ -38,33 +43,30 @@ before_install:

- php -S localhost:8080 -t tests/web &> /dev/null &
- ln -fs parameters.yml.dist tests/app/config/parameters.yml
- test "$SYMFONY_VERSION" -eq 4 || composer require --no-update "symfony/lts:^$SYMFONY_VERSION"
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
- cd tests/
- test "$SYMFONY_VERSION" -eq 4 || composer require --no-update "symfony/lts:^$SYMFONY_VERSION"
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
- cd ..

install:
- echo 'memory_limit=-1' > travis.php.ini
- phpenv config-add travis.php.ini

- composer update

- composer update -n --prefer-dist --prefer-stable $COMPOSER_FLAGS
- cd tests/
- composer update
- composer update -n --prefer-dist --prefer-stable $COMPOSER_FLAGS
- rm -rf vendor/pomm-project/pomm-bundle
- ln -s ../../../ vendor/pomm-project/pomm-bundle

before_script:
- |
export CURRENT_SYMFONY_VERSION=$( \
composer show --format=json \
| jq '.installed[] | select(.name == "symfony/symfony") | .version' \
| sed 's/^"v\([0-9]\+\)\.[^"]*"/\1/' \
)
- echo $CURRENT_SYMFONY_VERSION
- CHROME_MAIN_VERSION=`google-chrome-stable --version | sed -E 's/(^Google Chrome |\.[0-9]+ )//g'`
- CHROMEDRIVER_VERSION=`curl -s "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_MAIN_VERSION"`
- curl "https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip" -O
- unzip chromedriver_linux64.zip -d ~/bin

- wget "https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar" -O selenium.jar
- java -jar selenium.jar &> /dev/null &


script:
- ../vendor/bin/phpcs --standard=psr2 --runtime-set ignore_warnings_on_exit true --report=summary ../sources
- ./app/console pomm:generate:schema-all -d 'src/' -a 'AppBundle\Model' my_db1
- ./bin/behat --tags "~@upper${CURRENT_SYMFONY_VERSION}lts"
- ./bin/behat
- ./app/console pomm:generate:schema-all default_session_builder
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
}
],
"require": {
"php": ">=5.4.4",
"php": ">=7.1",
"jdorn/sql-formatter": "~1.2",
"pomm-project/model-manager": "~2.0",
"pomm-project/cli": "~2.0",
"pomm-project/pomm-symfony-bridge": "~2.5",
"symfony/framework-bundle": "~2.8|~3.0|~4.0"
"pomm-project/pomm-symfony-bridge": "~2.5|~3.0",
"symfony/framework-bundle": "^3.4|^4.3|^5.0"
},
"require-dev": {
"symfony/console": "~2.6|~3.0|~4.0",
"symfony/console": "^3.4|^4.3|^5.0",
"squizlabs/php_codesniffer": "~2.7"
},
"suggest": {
Expand Down
5 changes: 3 additions & 2 deletions sources/lib/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('pomm');
$treeBuilder = new TreeBuilder('pomm');
$rootNode = method_exists($treeBuilder, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('pomm');

$rootNode
->children()
->arrayNode('configuration')
Expand Down
6 changes: 3 additions & 3 deletions tests/app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ framework:
#translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
resource: "%kernel.project_dir%/app/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
templating:
engines: ['twig']

#assets_version: SomeVersionScheme
default_locale: "%locale%"
trusted_hosts: ~
Expand All @@ -30,6 +29,7 @@ framework:
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
paths: ['%kernel.project_dir%/templates']

pomm:
configuration:
Expand Down
2 changes: 1 addition & 1 deletion tests/app/config/config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ imports:

framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
resource: "%kernel.project_dir%/app/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }

Expand Down
7 changes: 5 additions & 2 deletions tests/app/console
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;

set_time_limit(0);

Expand All @@ -18,7 +17,11 @@ $env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?:
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';

if ($debug) {
Debug::enable();
if (class_exists('\Symfony\Component\ErrorHandler\Debug')) {
\Symfony\Component\ErrorHandler\Debug::enable();
}else{
\Symfony\Component\Debug\Debug::enable();
}
}

$kernel = new AppKernel($env, $debug);
Expand Down
16 changes: 14 additions & 2 deletions tests/behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ default:
- FeatureContext
- behatch:context:json
extensions:
Behat\MinkExtension\ServiceContainer\MinkExtension:
Behat\MinkExtension:
base_url: 'http://localhost:8080'
goutte: ~
browser_name: chrome
sessions:
default:
selenium2:
wd_host: "http://localhost:4444/wd/hub"
browser: chrome
capabilities:
extra_capabilities:
chromeOptions:
args:
- "--headless"
- "--disable-gpu"
- "--no-sandbox"
Behatch\Extension: ~
18 changes: 9 additions & 9 deletions tests/composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
{
"require": {
"symfony/symfony": "~2.8|~3.0|~4.0",
"symfony/symfony": "^3.4|^4.3|^5.0",
"symfony/monolog-bundle": "~3.0",
"twig/extensions": "~1.0",
"sensio/framework-extra-bundle": "~3.0,>=3.0.2|~4.0",
"sensio/framework-extra-bundle": "^3.4|^4.3|^5.0",
"pomm-project/cli": "~2.0",
"pomm-project/foundation": "~2.0",
"pomm-project/model-manager": "~2.0",
"pomm-project/pomm-bundle": "dev-master",
"pomm-project/pomm-symfony-bridge": "~2.5"
"pomm-project/pomm-symfony-bridge": "~2.5|dev-master",
"symfony/framework-bundle": "^3.4|^4.3|^5.0",
"jdorn/sql-formatter": "~1.2"
},
"require-dev": {
"behatch/contexts": "~2.7|~3.0",
"behat/mink-extension": "~2.2",
"behat/mink": "*@dev",
"behat/mink-browserkit-driver": "*@dev",
"behat/mink-goutte-driver": "*"
"behatch/contexts": "~3.0",
"behat/mink-selenium2-driver": "dev-master",
"instaclick/php-webdriver": "1.4.7"
},
"autoload": {
"psr-0": { "AppBundle\\": "src/" },
"psr-4": { "PommProject\\PommBundle\\": "../sources/lib/" },
"classmap": [ "app/AppKernel.php" ]
},
"autoload-dev": {
Expand Down
19 changes: 13 additions & 6 deletions tests/src/AppBundle/Controller/AutowireController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@
namespace AppBundle\Controller;
use AppBundle\Model\MyDb1\PublicSchema\ConfigModel;
use PommProject\Foundation\Pomm;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;

/**
* @author Mikael Paris <stood86@gmail.com>
*/
class AutowireController extends Controller
class AutowireController
{
public function getAutowireAction($name, Pomm $pomm)
public function getAutowireAction(
$name,
Pomm $pomm,
Environment $engine
)
{
$config = $pomm
->getDefaultSession()
->getModel(ConfigModel::class)
->findByPk(['name' => $name]);
return $this->render(
'AppBundle:Front:get.html.twig',

return new Response($engine->render(
'Front/get.html.twig',
compact('config')
);
));
}
}
20 changes: 10 additions & 10 deletions tests/src/AppBundle/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use \Symfony\Component\Serializer\Serializer;
use \Symfony\Component\HttpFoundation\Response;
use \Symfony\Component\Templating\EngineInterface;
use \Symfony\Component\PropertyInfo\PropertyInfoExtractor;
use \Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface;

class IndexController
{
Expand All @@ -20,10 +20,10 @@ class IndexController
private $serviceModel;

public function __construct(
EngineInterface $templating,
$templating,
Session $pomm,
Serializer $serializer,
PropertyInfoExtractor $property,
PropertyInfoExtractorInterface $property,
Session $serviceSession,
ServiceModel $serviceModel
) {
Expand All @@ -42,7 +42,7 @@ public function indexAction()

return new Response(
$this->templating->render(
'AppBundle:Front:index.html.twig'
'Front/index.html.twig'
)
);
}
Expand All @@ -51,7 +51,7 @@ public function getAction(Config $config = null)
{
return new Response(
$this->templating->render(
'AppBundle:Front:get.html.twig',
'Front/get.html.twig',
compact('config')
)
);
Expand All @@ -66,7 +66,7 @@ public function getDefaultSessionAction(Config $config)
{
return new Response(
$this->templating->render(
'AppBundle:Front:get.html.twig',
'Front/get.html.twig',
compact('config')
)
);
Expand All @@ -81,7 +81,7 @@ public function getSessionAction(Config $config)
{
return new Response(
$this->templating->render(
'AppBundle:Front:get.html.twig',
'Front/get.html.twig',
compact('config')
)
);
Expand All @@ -96,7 +96,7 @@ public function getSession2Action(Config $config)
{
return new Response(
$this->templating->render(
'AppBundle:Front:get.html.twig',
'Front/get.html.twig',
compact('config')
)
);
Expand Down Expand Up @@ -143,7 +143,7 @@ public function propertyListAction()

return new Response(
$this->templating->render(
'AppBundle:Front:properties.html.twig',
'Front/properties.html.twig',
compact('info')
)
);
Expand All @@ -155,7 +155,7 @@ public function propertyTypeAction($property)

return new Response(
$this->templating->render(
'AppBundle:Front:property.html.twig',
'Front/property.html.twig',
compact('info')
)
);
Expand Down
4 changes: 0 additions & 4 deletions tests/src/AppBundle/DependencyInjection/AppExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,5 @@ public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

if (version_compare(\Symfony\Component\HttpKernel\Kernel::VERSION, '3.3', '>=')) {
$loader->load('services_sf33.yml');
}
}
}
5 changes: 4 additions & 1 deletion tests/src/AppBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
index_controller:
class: AppBundle\Controller\IndexController
arguments: ['@templating', '@pomm.default_session', '@serializer', '@property_info', '@pomm.session.service_db', '@service_model']
arguments: ['@Twig_Environment', '@pomm.default_session', '@serializer', '@property_info', '@pomm.session.service_db', '@service_model']
public: true
service_model:
class: AppBundle\Model\MyDb1\PublicSchema\ServiceModel
Expand All @@ -12,3 +12,6 @@ services:
class: AppBundle\Controller\AutowireController
tags:
- { name: controller.service_arguments }
AppBundle\Model\MyDb1\PublicSchema\ConfigModel:
tags:
- { name: pomm.model, session: pomm.session.service_db }
4 changes: 0 additions & 4 deletions tests/src/AppBundle/Resources/config/services_sf33.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'AppBundle::layout.html.twig' %}
{% extends 'layout.html.twig' %}

{% block title %}
Pomm bundle test app
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'AppBundle::layout.html.twig' %}
{% extends 'layout.html.twig' %}

{% block title %}
Pomm bundle test app
Expand Down
Loading

0 comments on commit 50cb32a

Please sign in to comment.