{"id":18903593,"url":"https://github.com/intaro/symfony-testing-tools","last_synced_at":"2025-04-15T03:33:34.828Z","repository":{"id":56992265,"uuid":"54699690","full_name":"intaro/symfony-testing-tools","owner":"intaro","description":"Symfony testing tools","archived":false,"fork":false,"pushed_at":"2016-03-25T08:43:38.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-14T12:03:34.224Z","etag":null,"topics":[],"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/intaro.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}},"created_at":"2016-03-25T06:31:16.000Z","updated_at":"2024-05-14T12:03:34.226Z","dependencies_parsed_at":"2022-08-21T12:50:53.418Z","dependency_job_id":null,"html_url":"https://github.com/intaro/symfony-testing-tools","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fsymfony-testing-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fsymfony-testing-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fsymfony-testing-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/intaro%2Fsymfony-testing-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/intaro","download_url":"https://codeload.github.com/intaro/symfony-testing-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223657849,"owners_count":17181024,"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-08T09:05:52.016Z","updated_at":"2024-11-08T09:05:52.711Z","avatar_url":"https://github.com/intaro.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Symfony testing tools\n\nThe library contains improved classes of WebTestCase and Container for convenient testing.\n\n## Features\n\n### The Client local caching\n\nWeb Client is caching in WebTestCase. If you want to get a client you should use:\n```php\n$client = static::getClient();\n```\n\nIf you want to get a new client you should use:\n```php\n$client = static::getClient(true);\n```\n\nFull example:\n```php\n\u003c?php\nnamespace Foo\\BarBundle\\Tests\\Controller;\n\nuse Intaro\\SymfonyTestingTools\\WebTestCase;\n\nclass SomeControllerTest extends WebTestCase\n{\n    public function testIndex()\n    {\n        $client = static::getClient(true);\n        //...\n    }\n}\n```\n\n### Shortcuts for EntityManager and Container\n\nYou can simply get EntityManager or Container in the current context:\n\n```php\n\u003c?php\nnamespace Foo\\BarBundle\\Tests\\Controller;\n\nuse Intaro\\SymfonyTestingTools\\WebTestCase;\n\nclass SomeControllerTest extends WebTestCase\n{\n    public function testIndex()\n    {\n        $client = static::getClient(true);\n        \n        $em = static::getEntityManager();\n        $service = static::getContainer()-\u003eget('some_service');\n        //...\n    }\n}\n```\n\n### Checking a response HTTP code\n\nYou can check response result with the following methods:\n\n```php\n\u003c?php\n\nnamespace Foo\\BarBundle\\Tests\\Controller;\n\nuse Intaro\\SymfonyTestingTools\\WebTestCase;\n\nclass SomeControllerTest extends WebTestCase\n{\n    public function testIndex()\n    {\n        $client = static::getClient();\n\n        $client-\u003erequest('GET', '/foo/bar/index');\n        $this-\u003eassertResponseOk($client-\u003egetResponse(), 'Page opens');\n        $this-\u003eassertResponseRedirect($client-\u003egetResponse(), 'Page redirects to other page');\n        $this-\u003eassertResponseNotFound($client-\u003egetResponse(), 'Page not found');\n        $this-\u003eassertResponseForbidden($client-\u003egetResponse(), 'Page forbidden');\n        $this-\u003eassertResponseCode(201, $client-\u003egetResponse(), 'JSON returned', 'application/json');\n    }\n}\n```\n\n### Fixtures appending\n\nYou can add fixtures before test running:\n\n```php\n\u003c?php\n\nnamespace Foo\\BarBundle\\Tests\\Controller;\n\nuse Foo\\BarBundle\\DataFixtures\\ORM\\Test\\ActionRecordData;\nuse Intaro\\SymfonyTestingTools\\WebTestCase;\n\nclass SomeControllerTest extends WebTestCase\n{\n    public static function setUpBeforeClass()\n    {\n        static::appendFixture(new ActionRecordData, [\n            'purge' =\u003e true,\n        ]);\n    }\n\n    public function testIndex()\n    {\n        //...\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintaro%2Fsymfony-testing-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fintaro%2Fsymfony-testing-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fintaro%2Fsymfony-testing-tools/lists"}