2017 © Pedro Peláez
 

library symfony-bundle-test

image

nyholm/symfony-bundle-test

  • Monday, March 26, 2018
  • by Nyholm
  • Repository
  • 3 Watchers
  • 22 Stars
  • 12,214 Installations
  • PHP
  • 28 Dependents
  • 0 Suggesters
  • 6 Forks
  • 1 Open issues
  • 17 Versions
  • 33 % Grown

The README.md

Symfony Bundle Test

Total Downloads, (*1)

Test if your bundle is compatible with different Symfony versions, (*2)

When you want to make sure that your bundle works with different versions of Symfony you need to create a custom TestKernel and load your bundle and configuration., (*3)

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

Support

Currently supported PHP and Symfony Versions., (*5)

Branch PHP Version Symfony Version Supported
master 7.2+, 8.0+ 5.4, 6.0+, 7.0+ Yes
2.x 7.2+, 8.0+ 4.4, 6.3 - 6.4 no

Please always try to update to the latest version of this package before reporting an issue., (*6)

Install

Via Composer, (*7)

``` bash composer require --dev nyholm/symfony-bundle-test, (*8)


## Write a test ```php use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Nyholm\BundleTest\TestKernel; use Acme\AcmeFooBundle; use Acme\Service\Foo; use Symfony\Component\HttpKernel\KernelInterface; class BundleInitializationTest extends KernelTestCase { protected static function getKernelClass(): string { return TestKernel::class; } protected static function createKernel(array $options = []): KernelInterface { /** * @var TestKernel $kernel */ $kernel = parent::createKernel($options); $kernel->addTestBundle(AcmeFooBundle::class); $kernel->handleOptions($options); return $kernel; } public function testInitBundle(): void { // Boot the kernel. $kernel = self::bootKernel(); // Get the container $container = $kernel->getContainer(); // Or for FrameworkBundle@^5.3.6 to access private services without the PublicCompilerPass // $container = self::getContainer(); // Test if your services exists $this->assertTrue($container->has('acme.foo')); $service = $container->get('acme.foo'); $this->assertInstanceOf(Foo::class, $service); } public function testBundleWithDifferentConfiguration(): void { // Boot the kernel with a config closure, the handleOptions call in createKernel is important for that to work $kernel = self::bootKernel(['config' => static function(TestKernel $kernel){ // Add some other bundles we depend on $kernel->addTestBundle(OtherBundle::class); // Add some configuration $kernel->addTestConfig(__DIR__.'/config.yml'); }]); // ... } }

Configure Github Actions

You want "Github actions" to run against each currently supported LTS version of Symfony (since there would be only one per major version), plus the current if it's not an LTS too. There is no need for testing against version in between because Symfony follows Semantic Versioning., (*9)

Create a file in .github/workflows directory:, (*10)

#.github/workflows/php.yml
name: My bundle test

on:
  push: ~
  pull_request: ~

jobs:
  build:
    runs-on: ${{ matrix.operating-system }}
    name: PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }}
    strategy:
      matrix:
        operating-system: [ 'ubuntu-22.04', 'windows-2022' ]
        php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
        symfony: ['5.4.*', '6.4.*', '7.0.*']
        exclude:
        - php: '7.4'
          symfony: '6.4.*'
        - php: '8.0'
          symfony: '6.4.*'
        - php: '7.4'
          symfony: '7.0.*'
        - php: '8.0'
          symfony: '7.0.*'
        - php: '8.1'
          symfony: '7.0.*'

    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP ${{ matrix.php }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          tools: flex

      - name: Download dependencies
        env:
          SYMFONY_REQUIRE: ${{ matrix.symfony }}
        uses: ramsey/composer-install@v2

      - name: Run test suite on PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }}
        run: ./vendor/bin/phpunit

The Versions

02/02 2018

dev-Nyholm-patch-1

dev-Nyholm-patch-1

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

02/02 2018

dev-changelog

dev-changelog

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

02/02 2018

1.3.0

1.3.0.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

01/02 2018

dev-pass

dev-pass

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

27/12 2017

1.2.3

1.2.3.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

20/08 2017

1.2.2

1.2.2.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

20/08 2017

1.2.1

1.2.1.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

16/07 2017

1.2.0

1.2.0.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

14/07 2017

1.1.0

1.1.0.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

15/06 2017

1.0.2

1.0.2.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

28/03 2017

1.0.1

1.0.1.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires

21/12 2016

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

  • php ^5.5 || ^7.0

 

The Development Requires