All Projects → SymfonyTest → symfony-bundle-test

SymfonyTest / symfony-bundle-test

Licence: MIT License
Smoke test your Symfony bundle

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to symfony-bundle-test

LolautruchePaylineBundle
Symfony integration for Payline payment system
Stars: ✭ 15 (-82.56%)
Mutual labels:  symfony-bundle
acl-bundle
Integrates the ACL Security component into Symfony applications.
Stars: ✭ 91 (+5.81%)
Mutual labels:  symfony-bundle
time-ago-bundle
Provides a simple twig filter for expressing time difference in words.
Stars: ✭ 13 (-84.88%)
Mutual labels:  symfony-bundle
AutoFormBundle
Automate Symfony form building
Stars: ✭ 68 (-20.93%)
Mutual labels:  symfony-bundle
BeelabUserBundle
👥 Simple user management for Symfony.
Stars: ✭ 17 (-80.23%)
Mutual labels:  symfony-bundle
mongodb-migrations-bundle
Symfony MongoDBMigrationsBundle
Stars: ✭ 21 (-75.58%)
Mutual labels:  symfony-bundle
block-bundle
Extends the SonataBlockBundle to integrate with PHPCR ODM
Stars: ✭ 20 (-76.74%)
Mutual labels:  symfony-bundle
dataflow-bundle
Data processing framework inspired by PortPHP
Stars: ✭ 13 (-84.88%)
Mutual labels:  symfony-bundle
hcaptcha-bundle
A Symfony 4+ bundle to bring hCaptcha into your forms
Stars: ✭ 15 (-82.56%)
Mutual labels:  symfony-bundle
EasyAuditBundle
A Symfony Bundle To Log Selective Events
Stars: ✭ 84 (-2.33%)
Mutual labels:  symfony-bundle
DunglasTorControlBundle
Integration of PHP TorControl library in Symfony
Stars: ✭ 13 (-84.88%)
Mutual labels:  symfony-bundle
routing-auto-bundle
Adding automatic route generating on top of the symfony cmf routing
Stars: ✭ 14 (-83.72%)
Mutual labels:  symfony-bundle
domain-event-bundle
Library to create the domain layer of your DDD application
Stars: ✭ 14 (-83.72%)
Mutual labels:  symfony-bundle
docusign-bundle
Symfony bundle to create electronic signatures with DocuSign
Stars: ✭ 27 (-68.6%)
Mutual labels:  symfony-bundle
doctrine-json-odm
JSON Object-Document Mapping bundle for Symfony and Doctrine
Stars: ✭ 15 (-82.56%)
Mutual labels:  symfony-bundle
eav-bundle
A Symfony bundle for basic EAV management
Stars: ✭ 19 (-77.91%)
Mutual labels:  symfony-bundle
EzCoreExtraBundle
Extra features for eZ Platform (v1.x compatible with eZ Publish 5.4)
Stars: ✭ 29 (-66.28%)
Mutual labels:  symfony-bundle
WhiteOctoberAdminBundle
A different take on an AdminBundle for Symfony2
Stars: ✭ 83 (-3.49%)
Mutual labels:  symfony-bundle
KnpDisqusBundle
A Symfony bundle to fetch and render disqus comments via their API. Your SEO other-half will love it.
Stars: ✭ 62 (-27.91%)
Mutual labels:  symfony-bundle
health-check-bundle
A bundle that provides a simple /healthcheck route
Stars: ✭ 27 (-68.6%)
Mutual labels:  symfony-bundle

Symfony Bundle Test

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 TestKernel 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 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.

Create a file in .github/workflows directory:

#.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-latest, windows-latest ]
        php: [ '7.4', '8.0', '8.1' ]
        symfony: ['4.4.*', '5.3.*', '5.4.*', '6.0.*', '6.1.*']

    steps:
      - uses: actions/checkout@master

      - 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@v1

      - name: Run test suite on PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }}
        run: ./vendor/bin/phpunit
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].