{"id":15728640,"url":"https://github.com/stephenjude/api-test-helper","last_synced_at":"2025-04-14T13:08:59.570Z","repository":{"id":52999790,"uuid":"313092920","full_name":"stephenjude/api-test-helper","owner":"stephenjude","description":"A collection of helper methods for testing and debugging API endpoints.","archived":false,"fork":false,"pushed_at":"2023-08-14T11:21:57.000Z","size":37,"stargazers_count":48,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T00:35:28.423Z","etag":null,"topics":["api","api-testing","helpers","laravel","laravel-framework","testing"],"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/stephenjude.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-11-15T18:08:42.000Z","updated_at":"2024-03-29T17:10:01.000Z","dependencies_parsed_at":"2023-09-21T15:35:28.322Z","dependency_job_id":null,"html_url":"https://github.com/stephenjude/api-test-helper","commit_stats":{"total_commits":20,"total_committers":3,"mean_commits":6.666666666666667,"dds":0.5,"last_synced_commit":"b5f98400043de69328cfb1c9439af2deba76f1d0"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenjude%2Fapi-test-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenjude%2Fapi-test-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenjude%2Fapi-test-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stephenjude%2Fapi-test-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stephenjude","download_url":"https://codeload.github.com/stephenjude/api-test-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248886322,"owners_count":21177643,"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":["api","api-testing","helpers","laravel","laravel-framework","testing"],"created_at":"2024-10-03T23:05:08.835Z","updated_at":"2025-04-14T13:08:57.972Z","avatar_url":"https://github.com/stephenjude.png","language":"PHP","readme":"# Laravel API Test Helpers\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/stephenjude/api-test-helper.svg?style=flat-square)](https://packagist.org/packages/stephenjude/api-test-helper)\n[![Build Status](https://img.shields.io/travis/stephenjude/api-test-helper/master.svg?style=flat-square)](https://travis-ci.org/stephenjude/api-test-helper)\n[![Total Downloads](https://img.shields.io/packagist/dt/stephenjude/api-test-helper.svg?style=flat-square)](https://packagist.org/packages/stephenjude/api-test-helper)\n\nThis is a collection of helper methods for testing and debugging API endpoints.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require stephenjude/api-test-helper --dev\n```\n\n\n## Usage\n\n``` php\n\nnamespace Tests\\Apis;\n\nuse App\\Models\\User;\nuse Tests\\TestCase;\nuse Stephenjude\\ApiTestHelper\\WithApiHelper;\n\nclass UserApiTest extends TestCase\n{\n    use WithApiHelper;\n\n    /*\n    * @test\n    */\n    public function testGetAllUsers()\n    {\n        $actualUsers = User::all();\n\n        $this-\u003eresponse = $this-\u003egetJson('/users');\n\n        // Assert response is 200\n        $this-\u003eresponse-\u003eassertOk();\n\n        // Dump api data to the console\n        $this-\u003edumpApiData();\n\n        // Write api data to the log file\n        $this-\u003elogApiData();\n\n        // Return a decoded api response data\n        $responseData = $this-\u003edecodeApiResponse();\n\n        // Assert API data is a collection \n        $this-\u003eassertApiResponseCollection($actualUsers);\n    }\n}\n```\n\n## Available Helper Methods \n\nMethod | Description \n---------|----------\n `decodeApiResponse()` | Returns a decoded api response data. \n `dumpApiData()` | Dump api response data to the console. \n `logApiData()` | Write api response data to the log file.\n `assertApiSuccess()` | Assert api response data is successful: [success =\u003e true].\n `assertApiResponse($actualData)` | Assert api response data is same actual data item.\n `assertApiResponseCollection($actualData)` | Assert api response data is same actual collection items.\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email stephenjudesuccess@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Stephen Jude](https://github.com/stephenjude)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","funding_links":[],"categories":["Packages"],"sub_categories":["REST/Web Services"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenjude%2Fapi-test-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstephenjude%2Fapi-test-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstephenjude%2Fapi-test-helper/lists"}