Giter VIP home page Giter VIP logo

symfony-bundle-test's Introduction

Symfony Bundle Test

Latest Version Build Status Code Coverage Quality Score Total Downloads

Test if your bundle is compatible with different Symfony versions

When you want to make sure that your bundle works with different versions of Symfony you need to create a custom AppKernel and load your bundle and configuration.

Using this bundle test together with Matthias Nobacks's SymfonyDependencyInjectionTest will give you a good base for testing a Symfony bundle.

Install

Via Composer

$ composer require --dev nyholm/symfony-bundle-test

Write a test

use Nyholm\BundleTest\BaseBundleTestCase;
use Acme\AcmeFooBundle;
use Acme\Service\Foo;

class BundleInitializationTest extends BaseBundleTestCase
{
    protected function getBundleClass()
    {
        return AcmeFooBundle::class;
    }

    public function testInitBundle()
    {
        // Boot the kernel.
        $this->bootKernel();
        
        // Get the container
        $container = $this->getContainer();

        // Test if you services exists
        $this->assertTrue($container->has('acme.foo'));
        $service = $container->get('acme.foo');
        $this->assertInstanceOf(Foo::class, $service);
    }
    
    public function testBundleWithDifferentConfiguration()
    {
        // Create a new Kernel
        $kernel = $this->createKernel();
        
        // Add some configuration
        $kernel->addConfigFile(__DIR__.'/config.yml');
        
        // Add some other bundles we depend on
        $kernel->addBundle(OtherBundle::class);

        // Boot the kernel as normal ...
        $this->bootKernel();
        
        // ... 
    }
}

Configure travis

You want travis to run the highest version of Symfony you support and the lowest version. Same with PHP version. There is no need for testing for version in between because both Symfony and PHP follow Semver.

language: php

php:
    - 5.5
    - 7.1
    - hhvm
env:
  global:
    - TEST_COMMAND="vendor/bin/phpunit"
  matrix:
    - SYMFONY_VERSION=3.2.*    
    - SYMFONY_VERSION=2.7.*

matrix:
  fast_finish: true
  include:
    - php: 5.5
      env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_VERSION=2.7.* TEST_COMMAND="vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"

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

script:
    - $TEST_COMMAND

symfony-bundle-test's People

Contributors

bocharsky-bw avatar nyholm avatar stloyd avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.