{"id":19346964,"url":"https://github.com/protung/functional-test-bundle","last_synced_at":"2025-04-23T05:31:10.717Z","repository":{"id":9814768,"uuid":"63427205","full_name":"protung/functional-test-bundle","owner":"protung","description":"Symfony bundle for functional testing","archived":false,"fork":false,"pushed_at":"2024-05-29T08:37:05.000Z","size":336,"stargazers_count":5,"open_issues_count":3,"forks_count":6,"subscribers_count":5,"default_branch":"2.x","last_synced_at":"2024-05-29T20:45:19.546Z","etag":null,"topics":["php","symfony-bundle","testing"],"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/protung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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-07-15T14:18:35.000Z","updated_at":"2024-06-04T09:38:03.430Z","dependencies_parsed_at":"2023-12-14T08:29:36.369Z","dependency_job_id":"f3c28533-fd42-492b-aaaf-1f70579cc874","html_url":"https://github.com/protung/functional-test-bundle","commit_stats":{"total_commits":159,"total_committers":7,"mean_commits":"22.714285714285715","dds":0.6163522012578616,"last_synced_commit":"d8620a04d6cebe33db7adad4fa233dda71901c01"},"previous_names":["protung/functional-test-bundle"],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protung%2Ffunctional-test-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protung%2Ffunctional-test-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protung%2Ffunctional-test-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/protung%2Ffunctional-test-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/protung","download_url":"https://codeload.github.com/protung/functional-test-bundle/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223738616,"owners_count":17194580,"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":["php","symfony-bundle","testing"],"created_at":"2024-11-10T04:13:28.544Z","updated_at":"2024-11-10T04:13:29.181Z","avatar_url":"https://github.com/protung.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Speicher210 Functional Test Bundle\n\n## Introduction\n\nThis Bundle provides base classes and functionality for writing and running functional tests \nwith focus on testing REST endpoint.\nIt provides help in setting up test database and loading fixtures and mocking services in DI (even private services).\n\n## Installation\n\n### Download the Bundle\n\n```bash\n$ composer require --dev speicher210/functional-test-bundle\n```\n\n### Enable the Bundle\n\n#### Symfony\n```php\n\u003c?php\n// config/bundles.php\n\nreturn [\n    // ...\n    Speicher210\\FunctionalTestBundle\\Speicher210FunctionalTestBundle::class =\u003e ['dev' =\u003e true, 'test' =\u003e true],\n    // ...\n];\n```\n\n## Basic usage\n\nBootstrap for PHPUnit:\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nrequire dirname(__DIR__) . '/config/bootstrap.php';\nrequire_once dirname(__DIR__) . '/vendor/speicher210/functional-test-bundle/src/Test/bootstrap.php';\n\n// $kernel variable will contain the current Kernel instance\n\n```\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Speicher210\\FunctionalTestBundle\\Test\\RestControllerWebTestCase;\nuse Symfony\\Component\\HttpFoundation\\Request;\n\nfinal class MyUserEndpointTest extends RestControllerWebTestCase\n{\n    public function testReturn404IfUserIsNotFound() : void\n    {\n        $this-\u003eassertRestRequestReturns404('/api/user/1', Request::METHOD_GET);\n    }\n\n    public function testReturns200AndUserData() : void\n    {\n        $this-\u003eassertRestGetPath('/api/user/1');\n    }\n}\n```\n\nThe assertions are done using snapshots for comparison.\nBy default the framework will look under `Expected` directory (from where the test class is located) \nfor a file with the same name as the test and suffixed with `-1.json`.\n\nExample of expected output can be:\n`Expected/testReturns200AndUserData-1.json`\n```json\n{\n  \"id\": \"1\",\n  \"first_name\": \"John\",\n  \"last_name\": \"Doe\",\n  \"email\": \"@string@\",\n  \"sign_up_date_time\": \"@string@.isDateTime()\"\n}\n```\nThe `-1.json`suffix will be incremented for every REST assertion made under one test.\nIn the expected any functionality from `coduo/php-matcher` can be used.\n\nIt is possible to automatically update content of expected files during test execution to the actual content by adding \nthis extension to your phpunit config:\n\n```xml\n\u003cextensions\u003e\n    \u003cextension class=\"Speicher210\\FunctionalTestBundle\\Extension\\RestRequestFailTestExpectedOutputFileUpdater\" /\u003e\n\u003c/extensions\u003e\n```\n\nFixtures are loaded using Doctrine fixtures. \nBy default the framework will look by default under `Fixtures` directory (from where the test class is located)\nfor a PHP file with the same name as the test. This file must return an array of class names that extend \n`Speicher210\\FunctionalTestBundle\\Test\\Loader\\AbstractLoader` class.\nExample of fixture file can be:\n\n```php\n\u003c?php\n// Fixtures/testReturns200AndUserData.php\n\nreturn [\n    \\App\\Tests\\Fixtures\\Loader\\LoadOneUser::class\n];\n```\n\nIn order to rebuild and reset the database you need to create a bootstrap file for PHPUnit.\nIn your own bootstrap file you can include the file `Test/bootstrap.php` which will reset the test database.\nThe database will not be rebuild for every test, but only once when the tests start.\nThis means that data must be removed before running next test. This can be achieved by running tests in a transaction.\nFor this add the extension to your phpunit config:\n\n```xml\n\u003cextensions\u003e\n    \u003cextension class=\"DAMA\\DoctrineTestBundle\\PHPUnit\\PHPUnitExtension\" /\u003e\n\u003c/extensions\u003e\n```\n\n## Accessing and mocking services\n\nMocking services can be achieved by using\n\n```php\n\u003c?php\n\n$this-\u003emockContainerService('my_service_id', $myServiceMock);\n```\n\nServices can also be accessed by using\n```php\n\u003c?php\n\n$this-\u003egetContainerService('my_service_id');\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotung%2Ffunctional-test-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprotung%2Ffunctional-test-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprotung%2Ffunctional-test-bundle/lists"}