{"id":16816557,"url":"https://github.com/canvural/laravel-e2e-routes","last_synced_at":"2025-04-11T02:21:25.506Z","repository":{"id":62499441,"uuid":"239565849","full_name":"canvural/laravel-e2e-routes","owner":"canvural","description":"Set of routes to manage your data in E2E tests","archived":false,"fork":false,"pushed_at":"2020-04-18T15:43:24.000Z","size":77,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T23:41:28.736Z","etag":null,"topics":["cypress","e2e-testing","e2e-tests","laravel","php","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/canvural.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}},"created_at":"2020-02-10T17:04:05.000Z","updated_at":"2023-03-08T11:42:14.000Z","dependencies_parsed_at":"2022-11-02T11:46:54.897Z","dependency_job_id":null,"html_url":"https://github.com/canvural/laravel-e2e-routes","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/canvural%2Flaravel-e2e-routes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canvural%2Flaravel-e2e-routes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canvural%2Flaravel-e2e-routes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canvural%2Flaravel-e2e-routes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/canvural","download_url":"https://codeload.github.com/canvural/laravel-e2e-routes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248328436,"owners_count":21085317,"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":["cypress","e2e-testing","e2e-tests","laravel","php","testing"],"created_at":"2024-10-13T10:44:46.508Z","updated_at":"2025-04-11T02:21:25.475Z","avatar_url":"https://github.com/canvural.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Set of routes to manage your data in E2E tests\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/canvural/laravel-e2e-routes.svg?style=flat-square)](https://packagist.org/packages/canvural/laravel-e2e-routes)\n![Run tests](https://github.com/canvural/laravel-e2e-routes/workflows/Run%20tests/badge.svg?branch=master)\n[![Total Downloads](https://img.shields.io/packagist/dt/canvural/laravel-e2e-routes.svg?style=flat-square)](https://packagist.org/packages/canvural/laravel-e2e-routes)\n\n\nThis package provides a set of rules to help you manage your database state when running your E2E tests using Eloquent model factories.\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require --dev canvural/laravel-e2e-routes\n```\n\nIf you wish to customize some options, you may publish the config file with\n\n```bash\nphp artisan vendor:publish --provider=\"Vural\\E2ERoutes\\E2ERoutesServiceProvider\"\n```\n\nThis is the published config files contents. Here you can customize the route prefix which will be added to all the provided routes.Route names, and the namespace that all your models live in.\n```php\n\u003c?php\n\nreturn [\n    'prefix' =\u003e 'e2e',\n    'name' =\u003e 'e2e-routes',\n    'modelNamespace' =\u003e 'App\\\\',\n];\n\n```\n\n## Usage\n\nFor obvious reasons this package does not exposes the routes in the `production` environment. In other environments you can use the routes.\n\n#### Reset database (GET `e2e/reset`)\n\nYou can use the `http://localhost/e2e/reset` route to reset your database. Under the hood this route makes a call to `migrate:refresh` Artisan command. Also if you wish to `seed` your database after migrating, you may call the route with `seed` query string attached. `http://localhost/e2e/reset?seed` \n\n#### Creating models (POST `e2e/{modelName}`)\n\nThis package uses your Eloquent model factories to create the data.\n\nSo, for example if you have a model called `User` and the associated `UserFactory` you can make a POST request to the `http://localhost/e2e/user` endpoint to create a `User` in your database. Also, newly created model will be returned as a response from the endpoint.\n\nYou can substitute `user` in the above example with any model you want. If the given model is not found, a `404` response will be returned. Also, if the model exists but a factory for that model does not exists a `404` response will be returned.\n\n#### Overwriting attributes\n\nLike the `factory` method, this package also provides you an ability to overwrite models attributes. Simply add a body to your request like so:\n\n```php\n[\n    'attributes' =\u003e [ 'name' =\u003e 'John Doe' ]\n]\n```\nThis will overwrite the `name` attribute.\n\n#### Creating many models\n\nYou can specify how many model you want to create with\n```php\n[\n    'times' =\u003e 3\n]\n```\nThis will return an array containing 3 models.\n\n#### Using states\nIf you defined some states for your factories, you can use them when you are making the request.\n\n```php\n[\n    'states' =\u003e ['withAddress']\n]\n```\nThis will create your model with the `withAddress` state. If the given state is not endpoint will return a `404` response.\n\n#### All together\n```php\n[\n    'attributes' =\u003e [\n        'name' =\u003e 'John Doe',\n    ],\n    'states' =\u003e ['withAddress'],\n    'times' =\u003e 2\n]\n```\nYou can also combine the options like this.\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on 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 can.vural@aequitas-group.pl instead of using the issue tracker.\n\n## Credits\n\n- [Can Vural](https://github.com/CanVural)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanvural%2Flaravel-e2e-routes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanvural%2Flaravel-e2e-routes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanvural%2Flaravel-e2e-routes/lists"}