{"id":20620176,"url":"https://github.com/symfonytest/symfony-bundle-test","last_synced_at":"2025-04-04T21:11:12.744Z","repository":{"id":14759579,"uuid":"77034144","full_name":"SymfonyTest/symfony-bundle-test","owner":"SymfonyTest","description":"Smoke test your Symfony bundle","archived":false,"fork":false,"pushed_at":"2024-02-18T12:19:22.000Z","size":112,"stargazers_count":111,"open_issues_count":4,"forks_count":26,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-28T20:11:10.963Z","etag":null,"topics":["hacktoberfest","symfony","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SymfonyTest.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-21T08:45:27.000Z","updated_at":"2024-06-15T18:49:00.000Z","dependencies_parsed_at":"2023-12-09T02:28:32.068Z","dependency_job_id":"276787c2-a3fc-4ddd-9f3e-6dcb3c705866","html_url":"https://github.com/SymfonyTest/symfony-bundle-test","commit_stats":{"total_commits":79,"total_committers":19,"mean_commits":4.157894736842105,"dds":0.4177215189873418,"last_synced_commit":"ac04570711af15a66b85a0ebff700222f98a0814"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymfonyTest%2Fsymfony-bundle-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymfonyTest%2Fsymfony-bundle-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymfonyTest%2Fsymfony-bundle-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SymfonyTest%2Fsymfony-bundle-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SymfonyTest","download_url":"https://codeload.github.com/SymfonyTest/symfony-bundle-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247249532,"owners_count":20908212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","symfony","symfony-bundle"],"created_at":"2024-11-16T12:13:34.246Z","updated_at":"2025-04-04T21:11:12.714Z","avatar_url":"https://github.com/SymfonyTest.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony Bundle Test\n\n[![Total Downloads](https://img.shields.io/packagist/dt/nyholm/symfony-bundle-test.svg?style=flat-square)](https://packagist.org/packages/nyholm/symfony-bundle-test)\n\n**Test if your bundle is compatible with different Symfony versions**\n\nWhen you want to make sure that your bundle works with different versions of Symfony\nyou need to create a custom `TestKernel` and load your bundle and configuration.\n\nUsing this bundle test together with Matthias Nobacks's\n[SymfonyDependencyInjectionTest](https://github.com/SymfonyTest/SymfonyDependencyInjectionTest)\nwill give you a good base for testing a Symfony bundle.\n\n## Support\n\nCurrently supported PHP and Symfony Versions.\n\n| Branch | PHP Version             | Symfony Version | Supported |\n|--------|-------------------------|-----------------|-----------|\n| master | 7.2+, 8.0+              | 5.4, 6.0+, 7.0+ | Yes       |\n| 2.x    | 7.2+, 8.0+              | 4.4, 6.3 - 6.4  | no        |\n\nPlease always try to update to the latest version of this package before reporting an issue.\n\n## Install\n\nVia Composer\n\n``` bash\ncomposer require --dev nyholm/symfony-bundle-test\n```\n\n## Write a test\n\n```php\n\nuse Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase;\nuse Nyholm\\BundleTest\\TestKernel;\nuse Acme\\AcmeFooBundle;\nuse Acme\\Service\\Foo;\nuse Symfony\\Component\\HttpKernel\\KernelInterface;\n\nclass BundleInitializationTest extends KernelTestCase\n{\n    protected static function getKernelClass(): string\n    {\n        return TestKernel::class;\n    }\n\n    protected static function createKernel(array $options = []): KernelInterface\n    {\n        /**\n         * @var TestKernel $kernel\n         */\n        $kernel = parent::createKernel($options);\n        $kernel-\u003eaddTestBundle(AcmeFooBundle::class);\n        $kernel-\u003ehandleOptions($options);\n\n        return $kernel;\n    }\n\n    public function testInitBundle(): void\n    {\n        // Boot the kernel.\n        $kernel = self::bootKernel();\n\n        // Get the container\n        $container = $kernel-\u003egetContainer();\n\n        // Or for FrameworkBundle@^5.3.6 to access private services without the PublicCompilerPass\n        // $container = self::getContainer();\n\n        // Test if your services exists\n        $this-\u003eassertTrue($container-\u003ehas('acme.foo'));\n        $service = $container-\u003eget('acme.foo');\n        $this-\u003eassertInstanceOf(Foo::class, $service);\n    }\n\n    public function testBundleWithDifferentConfiguration(): void\n    {\n        // Boot the kernel with a config closure, the handleOptions call in createKernel is important for that to work\n        $kernel = self::bootKernel(['config' =\u003e static function(TestKernel $kernel){\n            // Add some other bundles we depend on\n            $kernel-\u003eaddTestBundle(OtherBundle::class);\n\n            // Add some configuration\n            $kernel-\u003eaddTestConfig(__DIR__.'/config.yml');\n        }]);\n\n        // ...\n    }\n}\n\n```\n\n## Configure Github Actions\n\nYou want [\"Github actions\"](https://docs.github.com/en/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](http://semver.org/spec/v2.0.0.html).\n\nCreate a file in .github/workflows directory:\n```yaml\n#.github/workflows/php.yml\nname: My bundle test\n\non:\n  push: ~\n  pull_request: ~\n\njobs:\n  build:\n    runs-on: ${{ matrix.operating-system }}\n    name: PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }}\n    strategy:\n      matrix:\n        operating-system: [ 'ubuntu-22.04', 'windows-2022' ]\n        php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]\n        symfony: ['5.4.*', '6.4.*', '7.0.*']\n        exclude:\n        - php: '7.4'\n          symfony: '6.4.*'\n        - php: '8.0'\n          symfony: '6.4.*'\n        - php: '7.4'\n          symfony: '7.0.*'\n        - php: '8.0'\n          symfony: '7.0.*'\n        - php: '8.1'\n          symfony: '7.0.*'\n\n    steps:\n      - uses: actions/checkout@v4\n\n      - name: Setup PHP ${{ matrix.php }}\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: ${{ matrix.php }}\n          tools: flex\n\n      - name: Download dependencies\n        env:\n          SYMFONY_REQUIRE: ${{ matrix.symfony }}\n        uses: ramsey/composer-install@v2\n\n      - name: Run test suite on PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }}\n        run: ./vendor/bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymfonytest%2Fsymfony-bundle-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsymfonytest%2Fsymfony-bundle-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsymfonytest%2Fsymfony-bundle-test/lists"}