Skip to content

Commit

Permalink
Allow Symfony 4.0 and 3.4
Browse files Browse the repository at this point in the history
* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* changes to use right testing branch

* DevKit updates

* fix composer.json

* DevKit updates

* fix testing dependency

* DevKit updates

* move into new test app structure, add missing dependencies

* remove some deprecated stuff, private services, twig runtime loader.

* add third option to load the renderer

* Apply fixes from StyleCI (#243)

[ci skip] [skip ci]

* make tests run

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* implementation for renderer copied from sonata

* DevKit updates

* do not call setEnvironment()

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* DevKit updates

* same as sonata does it

* let routing bundle load the old one too.

* remove symfony

* DevKit updates

* DevKit updates

* DevKit updates

* fix renderer issue for different versions in testing

* fixes due to hints on StyleCI

* lets try the latest routing-bundle fix on its branch

* back to normal versions

* user later testing version
  • Loading branch information
ElectricMaxxx committed Dec 5, 2017
1 parent 642ddaf commit 0676599
Show file tree
Hide file tree
Showing 25 changed files with 103 additions and 68 deletions.
4 changes: 1 addition & 3 deletions .gitignore
@@ -1,5 +1,3 @@
tests/Resources/app/cache
tests/Resources/app/logs
tests/Fixtures/App/var/
composer.lock
composer.phar
vendor
31 changes: 12 additions & 19 deletions .travis.yml
Expand Up @@ -26,45 +26,38 @@ cache:
- $HOME/.composer/cache/files

env:
matrix: SYMFONY_VERSION=3.4
matrix: SYMFONY_VERSION=4.0.*
global:
- SYMFONY_DEPRECATIONS_HELPER=48
- SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml" SYMFONY_PHPUNIT_VERSION=5.7
- SYMFONY_DEPRECATIONS_HELPER=0
- SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
- KERNEL_CLASS=Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Kernel
- SYMFONY_PHPUNIT_VERSION=5.7
- TEST_INSTALLATION=false

matrix:
include:
- php: 7.1
env: SYMFONY_VERSION=3.4.*
env: STABILITY=dev SYMFONY_VERSION=4.0.*
- php: 7.1
env: DEPS=dev SYMFONY_VERSION=3.3.*
- php: 5.6
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.0
env: SYMFONY_VERSION=3.1.*
- php: 7.0
env: SYMFONY_VERSION=3.2.*

env: STABILITY=dev COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.1
env: STABILITY=dev SYMFONY_VERSION=3.3.*
- php: 7.1
env: STABILITY=dev SYMFONY_VERSION=3.4.*
- env: TEST_INSTALLATION=true
fast_finish: true
allow_failures:
- php: 7.1
env: SYMFONY_VERSION=3.4.*
- env: TEST_INSTALLATION=true


before_install:
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi
- phpenv config-rm xdebug.ini || true
- composer self-update
- if [ "$DEPS" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; composer config prefer-stable true; fi;
- if [ "$SYMFONY_VERSION" != "" ]; then composer require symfony/symfony:${SYMFONY_VERSION} --no-update; fi
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)

install: travis_wait composer update --prefer-dist $COMPOSER_FLAGS

before_script: vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh

script:
- if [ "${TEST_INSTALLATION}" == true ]; then make test_installation; else make test; fi

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
@@ -1,8 +1,8 @@
Contributing
------------

Symfony2 CMF is an open source, community-driven project. We follow the same
guidelines as core Symfony2. If you'd like to contribute, please read the
Symfony CMF is an open source, community-driven project. We follow the same
guidelines as core Symfony. If you'd like to contribute, please read the
[Contributing Code][1] part of the documentation. If you're submitting a pull
request, please follow the guidelines in the [Submitting a Patch][2] section
and use the [Pull Request Template][3].
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -20,7 +20,7 @@ ifdef BRANCH
VERSION=dev-${BRANCH}
endif
PACKAGE=symfony-cmf/core-bundle

export KERNEL_CLASS=Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Kernel
list:
@echo 'test: will run all tests'
@echo 'unit_tests: will run unit tests only'
Expand All @@ -31,4 +31,5 @@ include ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk
include ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk
include ${TESTING_SCRIPTS_DIR}/make/test_installation.mk

.PHONY: test
test: unit_tests functional_tests_phpcr
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -12,7 +12,7 @@ Branch | Travis | Coveralls |
------ | ------ | --------- |
master | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] |

This bundle is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/) and licensed
This package is part of the [Symfony Content Management Framework (CMF)](http://cmf.symfony.com/) and licensed
under the [MIT License](LICENSE).

The CoreBundle for the Symfony content management framework provides common functionality,
Expand All @@ -22,8 +22,8 @@ a twig extension and php templating helper to walk PHPCR-ODM trees and support f

## Requirements

* PHP 5.6 / 7.0 / 7.1
* Symfony 2.8 / 3.1 / 3.2 / 3.3
* PHP 7.1
* Symfony 2.8 / 3.3 / 3.4 / 4.0
* See also the `require` section of [composer.json](composer.json)

## Documentation
Expand All @@ -44,10 +44,10 @@ For general support and questions, please use [StackOverflow](http://stackoverfl
## Contributing

Pull requests are welcome. Please see our
[CONTRIBUTING](https://github.com/symfony-cmf/symfony-cmf/blob/master/CONTRIBUTING.md)
[CONTRIBUTING](https://github.com/symfony-cmf/blob/master/CONTRIBUTING.md)
guide.

Unit and/or functional tests exist for this bundle. See the
Unit and/or functional tests exist for this package. See the
[Testing documentation](http://symfony.com/doc/master/cmf/components/testing.html)
for a guide to running the tests.

Expand Down
25 changes: 16 additions & 9 deletions composer.json
Expand Up @@ -2,7 +2,9 @@
"name": "symfony-cmf/core-bundle",
"type": "symfony-bundle",
"description": "Symfony CMF Core Bundle",
"keywords": ["Symfony CMF"],
"keywords": [
"Symfony CMF"
],
"homepage": "http://cmf.symfony.com",
"license": "MIT",
"authors": [
Expand All @@ -12,17 +14,23 @@
}
],
"require": {
"php": "^5.6|^7.0",
"symfony/framework-bundle": "^2.8|^3.0"
"php": "^7.1",
"symfony/framework-bundle": "^2.8 || ^3.3 || ^4.0"
},
"require-dev": {
"symfony/security-bundle": "^2.8|^3.0",
"symfony/phpunit-bridge": "^3.2",
"symfony/security-bundle": "^2.8 || ^3.3 || ^4.0",
"symfony/phpunit-bridge": "^3.3 || ^4.0",
"mockery/mockery": "^0.9.4",
"symfony-cmf/routing-bundle": "^2.0",
"symfony-cmf/testing": "^2.1@dev",
"symfony-cmf/testing": "^2.1",
"doctrine/dbal": "2.5.*",
"doctrine/phpcr-odm": "^1.0"
"doctrine/phpcr-odm": "^1.4|^2.0 ",
"symfony/browser-kit": "^2.8 || ^3.3 || ^4.0",
"symfony/templating": "^2.8 || ^3.3 || ^4.0",
"symfony/form": "^2.8 || ^3.3 || ^4.0",
"symfony/translation": "^2.8 || ^3.3 || ^4.0",
"symfony/validator": "^2.8 || ^3.3 || ^4.0",
"symfony/asset": "^2.8 || ^3.3 || ^4.0"
},
"suggest": {
"symfony/twig-bundle": "To get access to the CMF twig extension (^2.1)",
Expand All @@ -47,6 +55,5 @@
"branch-alias": {
"dev-master": "2.1-dev"
}
},
"prefer-stable": true
}
}
1 change: 1 addition & 0 deletions src/DependencyInjection/CmfCoreExtension.php
Expand Up @@ -331,6 +331,7 @@ private function loadPublishWorkflow($config, XmlFileLoader $loader, ContainerBu
$loader->load('publish-workflow.xml');

$container->setAlias('cmf_core.publish_workflow.checker', $config['checker_service']);
$container->getAlias('cmf_core.publish_workflow.checker')->setPublic(true);

if (false === $config['request_listener']
|| ('auto' === $config['request_listener'] && !class_exists(DynamicRouter::class))
Expand Down
Expand Up @@ -9,11 +9,11 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\DataFixture;
namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\DataFixture;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Document\RouteAware;

/**
* Fixtures class for test data.
Expand Down
Expand Up @@ -9,12 +9,12 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\DataFixture;
namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\DataFixture;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\PHPCR\Document\Generic;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\Content;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Document\Content;
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route;

/**
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document;
namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Document;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
Expand Down
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document;
namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Document;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface;
Expand Down
Expand Up @@ -9,19 +9,18 @@
* file that was distributed with this source code.
*/

namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App;

use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends TestKernel
class Kernel extends TestKernel
{
public function configure()
{
$this->requireBundleSets(['default', 'phpcr_odm']);

$this->addBundles([
new \Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle(),
new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
]);
$this->registerConfiguredBundles();
}

public function registerContainerConfiguration(LoaderInterface $loader)
Expand Down
18 changes: 18 additions & 0 deletions tests/Fixtures/App/config/bundles.php
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Symfony CMF package.
*
* (c) 2011-2017 Symfony CMF
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Cmf\Bundle\CoreBundle\CmfCoreBundle;
use Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle;

return [
CmfRoutingBundle::class => ['phpcr' => true],
CmfCoreBundle::class => ['phpcr' => true],
];
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -36,6 +36,7 @@ public function testPublishWorkflowDisabled()
]);

$this->container->setAlias('app.workflow_checker', 'cmf_core.publish_workflow.checker');
$this->container->getAlias('app.workflow_checker')->setPublic(true);

$this->container->compile();

Expand Down
44 changes: 31 additions & 13 deletions tests/Functional/Form/CheckboxUrlLabelFormTypeTest.php
Expand Up @@ -11,12 +11,14 @@

namespace Symfony\Cmf\Bundle\CoreBundle\Tests\Functional\Form;

use Symfony\Bridge\Twig\AppVariable;
use Symfony\Bridge\Twig\Command\DebugCommand;
use Symfony\Bridge\Twig\Extension\FormExtension;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Symfony\Bundle\TwigBundle\ContainerAwareRuntimeLoader;
use Symfony\Cmf\Bundle\CoreBundle\Form\Type\CheckboxUrlLabelFormType;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\DataFixture\LoadRouteData;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\DataFixture\LoadRouteData;
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
use Symfony\Component\Form\FormRenderer;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

class CheckboxUrlLabelFormTypeTest extends BaseTestCase
Expand All @@ -28,16 +30,6 @@ public function setUp()

public function testFormTwigTemplate()
{
$twig = $this->getContainer()->get('twig');
if (class_exists(ContainerAwareRuntimeLoader::class)) {
// TwigBridge 3.2+
$renderer = $twig->getRuntime(TwigRenderer::class);
} else {
$twig25 = !method_exists($twig, 'getRuntime');
$renderer = $twig->getExtension($twig25 ? 'form' : FormExtension::class)->renderer;
$renderer->setEnvironment($twig);
}

$view = $this->getContainer()->get('form.factory')->createNamedBuilder('name')
->add('terms', CheckboxUrlLabelFormType::class, [
'label' => '%a% and %b% and %c%',
Expand All @@ -50,10 +42,36 @@ public function testFormTwigTemplate()
->getForm()
->createView();

$template = $renderer->searchAndRenderBlock($view, 'widget', []);
$template = $this->getFormRenderer()->searchAndRenderBlock($view, 'widget', []);
$this->assertMatchesXpath($template, '//label[@class="checkbox"][contains(.,"/a and /b and http://localhost/hello/world")]');
}

/**
* @return FormRenderer|TwigRenderer
*/
private function getFormRenderer()
{
$twig = $this->getContainer()->get('twig');

// BC for Symfony < 3.2 where this runtime does not exists
if (!method_exists(AppVariable::class, 'getToken')) {
$twig25 = !method_exists($twig, 'getRuntime');

$renderer = $twig->getExtension($twig25 ? 'form' : FormExtension::class)->renderer;
$renderer->setEnvironment($twig);

return $renderer;
}
// BC for Symfony < 3.4 where runtime should be TwigRenderer
if (!method_exists(DebugCommand::class, 'getLoaderPaths')) {
$runtime = $twig->getRuntime(TwigRenderer::class);

return $runtime;
}

return $twig->getRuntime(FormRenderer::class);
}

protected function assertMatchesXpath($html, $expression, $count = 1)
{
$dom = new \DomDocument('UTF-8');
Expand Down
7 changes: 3 additions & 4 deletions tests/Functional/Templating/Helper/CmfHelperHierarchyTest.php
Expand Up @@ -13,16 +13,15 @@

use Doctrine\ODM\PHPCR\Document\Generic;
use Symfony\Cmf\Bundle\CoreBundle\Templating\Helper\CmfHelper;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\DataFixture\LoadHierarchyRouteData;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Resources\Document\RouteAware;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\DataFixture\LoadHierarchyRouteData;
use Symfony\Cmf\Bundle\CoreBundle\Tests\Fixtures\App\Document\RouteAware;
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;

class CmfHelperHierarchyTest extends BaseTestCase
{
/**
* @var SecurityContextInterface|\PHPUnit_Framework_MockObject_MockObject
* @var AuthorizationCheckerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $publishWorkflowChecker;

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/DependencyInjection/XmlSchemaTest.php
Expand Up @@ -18,7 +18,7 @@ class XmlSchemaTest extends XmlSchemaTestCase
public function testSchema()
{
$xmlFiles = array_map(function ($file) {
return __DIR__.'/../../Resources/Fixtures/config/'.$file;
return __DIR__.'/../../Fixtures/config/'.$file;
}, [
'config1.xml',
'config2.xml',
Expand Down

0 comments on commit 0676599

Please sign in to comment.