{"id":21421516,"url":"https://github.com/desarrolla2/test-bundle","last_synced_at":"2025-03-16T20:14:18.127Z","repository":{"id":56827342,"uuid":"122462022","full_name":"desarrolla2/test-bundle","owner":"desarrolla2","description":"This bundle allows you to perform functional tests quickly and easily with symfony.","archived":false,"fork":false,"pushed_at":"2023-05-11T11:40:38.000Z","size":86,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-26T05:36:23.589Z","etag":null,"topics":[],"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/desarrolla2.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-02-22T10:11:13.000Z","updated_at":"2022-04-02T10:32:32.000Z","dependencies_parsed_at":"2024-11-22T22:02:38.700Z","dependency_job_id":null,"html_url":"https://github.com/desarrolla2/test-bundle","commit_stats":{"total_commits":87,"total_committers":4,"mean_commits":21.75,"dds":0.3908045977011494,"last_synced_commit":"a40375fccf9a55520b434c87dcad26cf002c192e"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desarrolla2%2Ftest-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desarrolla2%2Ftest-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desarrolla2%2Ftest-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desarrolla2%2Ftest-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/desarrolla2","download_url":"https://codeload.github.com/desarrolla2/test-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243926073,"owners_count":20369910,"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":[],"created_at":"2024-11-22T20:35:42.472Z","updated_at":"2025-03-16T20:14:18.104Z","avatar_url":"https://github.com/desarrolla2.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TestBundle\n\nThis bundle allows you to perform functional tests quickly and easily with symfony.\n\n## Instalation\n\nIt is best installed it through [packagist](http://packagist.org/packages/desarrolla2/test-bundle) \nby including `desarrolla2/test-bundle` in your project composer.json require:\n\n``` json\n    \"require\": {\n        // ...\n        \"desarrolla2/test-bundle\":  \"*\"\n    }\n```\n\n## Usage\n\nYou just have to extend WebTestCase to start using the power of this bundle.\n\n``` php\nuse Desarrolla2\\TestBundle\\Functional\\WebTestCase \n\nclass ActivityTest extends WebTestCase\n\n```\n\n## Examples\n\nHere are some examples\n\n1. make a request and check that the answer is a 200 in html\n\n``` php\nclass ActivityTest extends WebTestCase\n{\n    public function testIndex()\n    {\n        $client = $this-\u003egetClient();\n        $user = $this-\u003elogIn($client, 'daniel@devtia.com', $this-\u003egetBackendRoles());\n\n        $this-\u003erequestAndAssertOkAndHtml(\n            $client,\n            'GET',\n            '_app.activity.index'\n        );\n    }        \n}\n```    \n\n2. complete a form, send it and check that a 301 returns. We always do redirect, when a form has passed the validation.\n\n``` php\nclass ProfileTest extends WebTestCase\n{\n    public function testChangePassword()\n    {\n        $client = $this-\u003egetClient();\n        $user = $this-\u003elogIn($client, 'daniel@devtia.com', $this-\u003egetBackendRoles());\n\n        $this-\u003erequestGetAndPostAndAssertRedirect(\n            $client,\n            '_app.profile.password',\n            [],\n            'form',\n            ['password' =\u003e ['first' =\u003e 'changeM3', 'second' =\u003e 'changeM3']]\n        );\n    }        \n}\n```    \n\nAs you can see, doing functional tests with this bundle is really easy. Go ahead and discover all the utilities that it \nbrings\n\n## Reporting\n\nEach time a request is executed, the result of the response is stored in `desarrolla2.request.latest`. \nIf you have phpunit configured to stop when it fails, here you will have in HTML format the response of the request \nthat failed, which will allow you to find the error more quickly.\n\nThe bundle also brings the command `php bin / console phpunit: statistics --env = test` if you execute it it will show \nyou:\n\n1. A summary of the time taken to execute the tests, how many requests were made, average per request and number of \nroutes not tested.\n\n```txt\n╰─$ php bin/console phpunit:statistics --env=test\n+--------------------------+----------+------------+\n| name                     | number   | percentage |\n+--------------------------+----------+------------+\n| Total execution time     | 1m23s    |            |\n| Total requests           | 848      |            |\n| Average time per request | 200ms    |            |\n| Total routes             | 538      |            |\n| Tested routes            | 470      | (87.36%)   |\n| Pending routes           | 68       | (12.64%)   |\n+--------------------------+----------+------------+\n```\n\n2. In the file `desarrolla2.routes.tested.txt` the detail of all the requests that were made, and how long it took to \nexecute each one.\n\n```txt\n╰─$ cat var/logs/desarrolla2.routes.tested.txt\n001. GET _api.activity.index ~0.152\n   - /admin/api/activity/1 0.152\n002. GET _api.contact.email ~0.168\n   - /admin/api/contact/115148/email/daniel@devtia.com 0.168\n003. GET _api.contact.phone ~0.128\n   - /admin/api/contact/115148/phone/653965048 0.128\n004. GET _api.service.index ~0.125\n   - /admin/api/service/ 0.125\n005. GET _api.sidebar.toggle ~0.091\n   - /admin/api/sidebar/toggle 0.091\n006. GET _app.activity.index ~2.533\n[...]\n```\n\n3. In the file `desarrolla2.tested.pending.txt` the detail of the routes that have not been tested.\n\n```txt\n╰─$ cat var/logs/desarrolla2.routes.pending.txt\n01. GET  _app.report.billing.payment\n02. POST _app.transport.locator.view\n03. GET  _app_admin_billing_invoice_batch\n04. GET  _app_admin_contact_batch\n05. GET  _app_admin_file_file_list\n06. GET  _app_admin_participant_batch\n07. GET  _public.contract.back\n08. GET  _public.file.download\n09. GET  _public.proposal.view\n10. GET  _student.default.switch\n[...]\n```\n4. In the file `desarrolla2.classes.profile.txt` the detail of the tests executed, and how long it took to execute each one\n\n```txt\n╰─$ cat var/logs/desarrolla2.classes.profile.txt\nPublicBundle\\Functional\\Api\\ProvinceTest: 241ms\n - testIndex: 241ms\nAppBundle\\Functional\\FosUserTest: 438ms\n - testDefault: 438ms\nAppBundle\\Functional\\Admin\\MailTest: 499ms\n - testDefault: 499ms\nAppBundle\\Functional\\Admin\\ConfigurationTest: 712ms\n - testDefault: 712ms\nAppBundle\\Functional\\DefaultTest: 729ms\n - testIndex: 729ms\nAppBundle\\Functional\\Admin\\LanguageTest: 759ms\n - testDefault: 759ms\nAppBundle\\Functional\\File\\FileTest: 775ms\n - testCategory: 775ms\nPublicBundle\\Functional\\Api\\HealthCheckTest: 779ms\n - testIndex: 156ms\n - testSwagger: 623ms\n[...]\n```\n\n## Contact\n\nYou can contact with me on [@desarrolla2](https://twitter.com/desarrolla2). \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesarrolla2%2Ftest-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesarrolla2%2Ftest-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesarrolla2%2Ftest-bundle/lists"}