Skip to content

Commit

Permalink
Merge pull request #289 from greg0ire/improve-travis-build
Browse files Browse the repository at this point in the history
Fix the build
  • Loading branch information
GuilhemN authored Oct 3, 2017
2 parents 0808db9 + 565ebe1 commit 1e5edb1
Show file tree
Hide file tree
Showing 28 changed files with 524 additions and 28 deletions.
30 changes: 20 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
language: php
dist: trusty

php:
- 5.5
- 5.6
- 7.0
- hhvm
- 7.1
- 7.2

branches:
only:
- master
- /^\d+\.\d+$/

env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors

sudo: false

cache:
Expand All @@ -22,25 +26,31 @@ matrix:
fast_finish: true
include:
- php: 5.3
env: SYMFONY_DEPRECATIONS_HELPER=weak
dist: precise
- php: 5.3
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_DEPRECATIONS_HELPER=weak
dist: precise
env: SYMFONY_DEPRECATIONS_HELPER COMPOSER_FLAGS="--prefer-lowest"
- php: 5.4
env: SYMFONY_DEPRECATIONS_HELPER=weak
- php: 7.0
env: SYMFONY_VERSION=2.7.* SYMFONY_DEPRECATIONS_HELPER=weak
env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors SYMFONY_VERSION=2.7.*
- php: 7.0
env: SYMFONY_VERSION=2.8.* COVERAGE=true SYMFONY_DEPRECATIONS_HELPER=weak
env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors SYMFONY_VERSION=2.8.* COVERAGE=true
- php: 7.0
env: SYMFONY_VERSION=3.0.*
env: SYMFONY_DEPRECATIONS_HELPER=weak_vendors SYMFONY_VERSION=3.2.*
- php: 7.1
env: ~
allow_failures:
- php: 7.1
env: ~

before_script:
- if [ "$COVERAGE" != "true" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi
- if [ "$COVERAGE" != "true" ]; then phpenv config-rm xdebug.ini; fi
- composer self-update
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --dev --no-update symfony/symfony=$SYMFONY_VERSION; fi
- composer update $COMPOSER_FLAGS --prefer-source
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- composer update $COMPOSER_FLAGS --prefer-dist --no-interaction

script: if [ "$COVERAGE" == "true" ]; then ./phpunit --coverage-clover=clover; else ./phpunit; fi
script: if [ "$COVERAGE" == "true" ]; then vendor/bin/phpunit --coverage-clover=clover; else vendor/bin/phpunit; fi

after_success:
- if [ "$COVERAGE" == "true" ]; then curl -sL https://bit.ly/artifact-uploader | php; fi
32 changes: 32 additions & 0 deletions Tests/BaseTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/*
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\DiExtraBundle\Tests;

use PHPUnit\Framework\TestCase;

abstract class BaseTestCase extends TestCase
{
final protected function createMock($class)
{
if (method_exists('PHPUnit\Framework\TestCase', 'createMock')) {
return parent::createMock($class);
}
return $this->getMock($class);
}
}
5 changes: 3 additions & 2 deletions Tests/DependencyInjection/Collection/LazyServiceMapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
namespace JMS\DiExtraBundle\Tests\DependencyInjection\Collection;

use JMS\DiExtraBundle\DependencyInjection\Collection\LazyServiceMap;
use JMS\DiExtraBundle\Tests\BaseTestCase;
use PHPUnit_Framework_MockObject_MockObject;
use Symfony\Component\DependencyInjection\ContainerInterface;

class LazyServiceMapTest extends \PHPUnit_Framework_TestCase
class LazyServiceMapTest extends BaseTestCase
{
/**
* @var LazyServiceMap
Expand Down Expand Up @@ -79,7 +80,7 @@ public function testIterator()

protected function setUp()
{
$this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$this->container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');

$this->map = new LazyServiceMap($this->container, array(
'foo' => 'bar_service',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
namespace JMS\DiExtraBundle\Tests\DependencyInjection\Collection;

use JMS\DiExtraBundle\DependencyInjection\Collection\LazyServiceSequence;
use JMS\DiExtraBundle\Tests\BaseTestCase;

class LazyServiceSequenceTest extends \PHPUnit_Framework_TestCase
class LazyServiceSequenceTest extends BaseTestCase
{
private $container;
private $seq;
Expand Down Expand Up @@ -75,7 +76,7 @@ public function testGet()

protected function setUp()
{
$this->container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$this->container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
$this->seq = new LazyServiceSequence($this->container, array('foo', 'bar', 'baz'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
use Doctrine\Common\Annotations\AnnotationReader;
use JMS\DiExtraBundle\DependencyInjection\Compiler\AnnotationConfigurationPass;
use JMS\DiExtraBundle\DependencyInjection\JMSDiExtraExtension;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Filesystem\Filesystem;

class AnnotationConfigurationPassTest extends \PHPUnit_Framework_TestCase
class AnnotationConfigurationPassTest extends TestCase
{
public function testProcess()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler;

use JMS\DiExtraBundle\DependencyInjection\Compiler\LazyServiceMapPass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class LazyServiceMapPassTest extends \PHPUnit_Framework_TestCase
class LazyServiceMapPassTest extends TestCase
{
public function testProcess()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler;

use JMS\DiExtraBundle\DependencyInjection\Compiler\LazyServiceSequencePass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

class LazyServiceSequencePassTest extends \PHPUnit_Framework_TestCase
class LazyServiceSequencePassTest extends TestCase
{
public function testProcess()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
namespace JMS\DiExtraBundle\Tests\DependencyInjection\Compiler;

use JMS\DiExtraBundle\DependencyInjection\Compiler\ResourceOptimizationPass;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\DirectoryResource;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class ResourceOptimizationPassTest extends \PHPUnit_Framework_TestCase
class ResourceOptimizationPassTest extends TestCase
{
public function testProcess()
{
Expand Down
4 changes: 3 additions & 1 deletion Tests/Finder/AbstractPatternFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

namespace JMS\DiExtraBundle\Tests\Finder;

abstract class AbstractPatternFinderTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

abstract class AbstractPatternFinderTest extends TestCase
{
public function testFindFiles()
{
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public function registerBundles()
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new \JMS\AopBundle\JMSAopBundle(),
version_compare(PHP_VERSION, '7.0.0', '<')?
new \JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\JMSDiExtraTestBundle():
new \JMS\DiExtraBundle\Tests\Functional\Bundle\TestBundle\JMSDiExtraTestBundle(),
new \JMS\DiExtraBundle\JMSDiExtraBundle(),
new \JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/*
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller;

use JMS\SecurityExtraBundle\Annotation\Secure;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
* Secured Controller.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
class AnotherSecuredController
{
/**
* @Route("/secure-action")
* @Secure("ROLE_FOO")
*/
public function secureAction()
{
throw new \Exception('Should never be called');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

/*
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Templating\EngineInterface;

class AutomaticallyInjectedController
{
private $context;
private $templating;
private $router;
private $foo;

public function setRouter(RouterInterface $router)
{
$this->router = $router;
}

/**
* @Route("/automatic-controller-injection-test")
*/
public function testAction()
{
$content = '';

$content .= sprintf("\$context injection: %s\n", $this->context instanceof SecurityContextInterface || $this->context instanceof AuthorizationCheckerInterface ? 'OK' : 'FAILED');
$content .= sprintf("\$templating injection: %s\n", $this->templating instanceof EngineInterface ? 'OK' : 'FAILED');
$content .= sprintf("\$router injection: %s\n", $this->router instanceof RouterInterface ? 'OK' : 'FAILED');
$content .= sprintf("\$foo injection: %s\n", 'bar' === $this->foo ? 'OK' : 'FAILED');

return new Response($content);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller;

use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpFoundation\Response;

/**
* @DI\Service("controller.extended_hello", parent = "controller.hello")
*/
class ExtendedServiceController extends ServiceController
{
public function helloAction()
{
return new Response('hello');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace JMS\DiExtraBundle\Tests\Functional\Bundle\LegacyTestBundle\Controller;

use JMS\DiExtraBundle\Annotation as DI;
use Symfony\Component\HttpFoundation\Response;

/**
* @DI\Service("controller.invokable")
*/
class InvokableServiceController
{
public function __invoke()
{
return new Response('invoked');
}
}
Loading

0 comments on commit 1e5edb1

Please sign in to comment.