{"id":20674709,"url":"https://github.com/rich-id/unit-bundle","last_synced_at":"2025-06-13T17:37:46.158Z","repository":{"id":53101598,"uuid":"237994669","full_name":"rich-id/unit-bundle","owner":"rich-id","description":"A Unit test bundle for Symfony 4.4","archived":false,"fork":false,"pushed_at":"2022-03-02T16:31:29.000Z","size":502,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T21:23:22.550Z","etag":null,"topics":["symfony","symfony-bundle","symfony4","test-driven-development","testing-tools"],"latest_commit_sha":null,"homepage":null,"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/rich-id.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-03T15:15:23.000Z","updated_at":"2020-06-18T08:48:25.000Z","dependencies_parsed_at":"2022-08-30T17:51:16.249Z","dependency_job_id":null,"html_url":"https://github.com/rich-id/unit-bundle","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/rich-id/unit-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-id%2Funit-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-id%2Funit-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-id%2Funit-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-id%2Funit-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rich-id","download_url":"https://codeload.github.com/rich-id/unit-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rich-id%2Funit-bundle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259690022,"owners_count":22896757,"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":["symfony","symfony-bundle","symfony4","test-driven-development","testing-tools"],"created_at":"2024-11-16T21:06:46.581Z","updated_at":"2025-06-13T17:37:46.098Z","avatar_url":"https://github.com/rich-id.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Getting Started With RichCongressUnitBundle\n=======================================\n\nThis version of the bundle requires Symfony 4.4+ and PHP 7.3+.\n\n[![Package version](https://img.shields.io/packagist/v/richcongress/unit-bundle)](https://packagist.org/packages/richcongress/unit-bundle)\n[![Build Status](https://img.shields.io/travis/richcongress/unit-bundle.svg?branch=master)](https://travis-ci.org/richcongress/unit-bundle?branch=master)\n[![Coverage Status](https://coveralls.io/repos/github/richcongress/unit-bundle/badge.svg?branch=master)](https://coveralls.io/github/richcongress/unit-bundle?branch=master)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/richcongress/unit-bundle/issues)\n[![License](https://img.shields.io/badge/license-MIT-red.svg)](LICENSE.md)\n\nThe unit-bundle provides is suite for application testing. It provides wrappers to isolate tests, various test cases to avoid code redundancy and a easy fixtures management.\n\nThis bundle is a fork of the [chaplean/unit-bundle](https://github.com/chaplean/unit-bundle).\n\n\n# Quick start\n\nThe unit-bundle requires almost no configuration but provides useful tools to test your code. Here is an basic example:\n\n```php\nclass MainControllerTest extends ControllerTestCase\n{\n    /**\n     * @WithFixtures\n     * \n     * @return void\n     */\n    public function testIndex(): void\n    {\n        $client = self::createClient();\n        $client-\u003erequest('GET', '/');\n    \n        self::assertStatusCode(Response::HTTP_OK, $client);\n    }\n\n    /**\n     * @WithFixtures\n     * \n     * @return void\n     */\n    public function testUserEdition(): void\n    {\n        $client = $this-\u003ecreateClientWith('user-1');\n        $client-\u003erequest('PUT', '/rest/users/self', ['name' =\u003e 'Karl']);\n    \n        self::assertStatusCode(Response::HTTP_OK, $client);\n    \n        $content = self::getJsonContent($client);\n        self::assertArrayKeyExists('name', $content);\n        self::assertSame('Karl', $content['name']);\n    }\n}\n```\n\n\n# Table of content\n\n1. [Installation](#1-installation)\n2. [Getting started](#2-getting-started)\n    - [Configuration](Docs/Configuration.md)\n    - [Available test cases](Docs/TestCases.md)\n        - [CommandTestCase](Docs/TestCases.md#commandtestcase)\n        - [ConstraintTestCase](Docs/TestCases.md#constrainttestcase)\n        - [ControllerTestCase](Docs/TestCases.md#controllertestcase)\n        - [RepositoryTestCase](Docs/TestCases.md#repositorytestcase)\n        - [VoterTestCase](Docs/TestCases.md#votertestcase)\n    - [Using the annotations](Docs/Annotations.md)\n    - [Creating fixtures](Docs/TestFixtures.md)\n    - [Overriding services with stub services](Docs/OverrideServices.md#overriding-services-with-stub-services)\n    - [Use dynamic mocks (legacy)](Docs/OverrideServices.md#use-dynamic-mocks-legacy)\n    - [Available default service stubs](Docs/OverrideServices.md#available-default-service-stubs)\n    - [Role provider](Docs/RolesProvider.md)\n4. [Versioning](#3-versioning)\n5. [Contributing](#4-contributing)\n6. [Hacking](#5-hacking)\n7. [License](#6-license)\n\n\n# 1. Installation\n\nThis version of the bundle requires Symfony 4.4+ and PHP 7.3+.\n\n### 1.1 Composer\n\n```bash\ncomposer require richcongress/unit-bundle\n```\n\n### 1.2 Bundles declaration\n\nAfter the installation, make sure that those 4 bundles are declared correctly within the Kernel's bundles list.\n\n```php\nnew Doctrine\\Bundle\\FixturesBundle\\DoctrineFixturesBundle::class =\u003e ['test' =\u003e true],\nnew Liip\\FunctionalTestBundle\\LiipFunctionalTestBundle::class    =\u003e ['test' =\u003e true],\nnew Liip\\TestFixturesBundle\\LiipTestFixturesBundle::class        =\u003e ['test' =\u003e true],\nnew RichCongress\\Bundle\\UnitBundle\\RichCongressUnitBundle::class =\u003e ['test' =\u003e true],\n```\n\n## 1.3 Declare the PHP Extension\n\nFirst and foremost, declare the PHPUnitExtension in the `phpunit.xml.dist`:\n\n```xml\n...\n\n\u003cextensions\u003e\n    \u003cextension class=\"RichCongress\\Bundle\\UnitBundle\\PHPUnit\\PHPUnitExtension\" /\u003e\n\u003c/extensions\u003e\n\n...\n```\n\n## 1.4 Mandatory configuration \n\nBy default, the bundle configures everything on its own but if the config has been overriden somewhere, you can override it back to the default by importing the configuration:\n\n```yaml\nimports:\n    - { resource: '@RichCongressUnitBundle/Resources/config/config.yml' }\n```\n\nOr configure manually doctrine with something like this:\n\n```yaml\nparameters:\n    doctrine.dbal.connection_factory.class: Liip\\TestFixturesBundle\\Factory\\ConnectionFactory\n\ndoctrine:\n    dbal:\n        driver: pdo_sqlite\n        user: test\n        path: '%kernel.cache_dir%/test.db'\n        url: null\n        memory: false\n```\n\n\n# 2. Getting started\n\n- [Configuration](Docs/Configuration.md)\n- [Available test cases](Docs/TestCases.md)\n    - [CommandTestCase](Docs/TestCases.md#commandtestcase)\n    - [ConstraintTestCase](Docs/TestCases.md#constrainttestcase)\n    - [ControllerTestCase](Docs/TestCases.md#controllertestcase)\n    - [RepositoryTestCase](Docs/TestCases.md#repositorytestcase)\n    - [VoterTestCase](Docs/TestCases.md#votertestcase)\n- [Using the annotations](Docs/Annotations.md)\n- [Creating fixtures](Docs/TestFixtures.md)\n- [Overriding services with stub services](Docs/OverrideServices.md#overriding-services-with-stub-services)\n- [Use dynamic mocks (legacy)](Docs/OverrideServices.md#use-dynamic-mocks-legacy)\n- [Available default service stubs](Docs/OverrideServices.md#available-default-service-stubs)\n- [Role provider](Docs/RolesProvider.md)\n\n\n# 3. Versioning\n\nunit-bundle follows [semantic versioning](https://semver.org/). In short the scheme is MAJOR.MINOR.PATCH where\n1. MAJOR is bumped when there is a breaking change,\n2. MINOR is bumped when a new feature is added in a backward-compatible way,\n3. PATCH is bumped when a bug is fixed in a backward-compatible way.\n\nVersions bellow 1.0.0 are considered experimental and breaking changes may occur at any time.\n\n\n# 4. Contributing\n\nContributions are welcomed! There are many ways to contribute, and we appreciate all of them. Here are some of the major ones:\n\n* [Bug Reports](https://github.com/richcongress/unit-bundle/issues): While we strive for quality software, bugs can happen and we can't fix issues we're not aware of. So please report even if you're not sure about it or just want to ask a question. If anything the issue might indicate that the documentation can still be improved!\n* [Feature Request](https://github.com/richcongress/unit-bundle/issues): You have a use case not covered by the current api? Want to suggest a change or add something? We'd be glad to read about it and start a discussion to try to find the best possible solution.\n* [Pull Request](https://github.com/richcongress/unit-bundle/merge_requests): Want to contribute code or documentation? We'd love that! If you need help to get started, GitHub as [documentation](https://help.github.com/articles/about-pull-requests/) on pull requests. We use the [\"fork and pull model\"](https://help.github.com/articles/about-collaborative-development-models/) were contributors push changes to their personnal fork and then create pull requests to the main repository. Please make your pull requests against the `master` branch.\n\nAs a reminder, all contributors are expected to follow our [Code of Conduct](CODE_OF_CONDUCT.md).\n\n\n# 5. Hacking\n\nYou might use Docker and `docker-compose` to hack the project. Check out the following commands.\n\n```bash\n# Start the project\ndocker-compose up -d\n\n# Install dependencies\ndocker-compose exec application composer install\n\n# Run tests\ndocker-compose exec application bin/phpunit\n\n# Run a bash within the container\ndocker-compose exec application bash\n```\n\n\n# 6. License\n\nunit-bundle is distributed under the terms of the MIT license.\n\nSee [LICENSE](LICENSE.md) for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frich-id%2Funit-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frich-id%2Funit-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frich-id%2Funit-bundle/lists"}