{"id":15645537,"url":"https://github.com/dmitry-ivanov/laravel-testing-tools","last_synced_at":"2025-04-05T03:11:36.534Z","repository":{"id":49806541,"uuid":"75414626","full_name":"dmitry-ivanov/laravel-testing-tools","owner":"dmitry-ivanov","description":"Laravel-specific Testing Helpers and Assertions.","archived":false,"fork":false,"pushed_at":"2025-03-06T14:28:26.000Z","size":836,"stargazers_count":54,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-01T21:11:41.848Z","etag":null,"topics":["assertion-functions","assertion-methods","assertions","helpers","laravel","laravel-package","testing","tools"],"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/dmitry-ivanov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2016-12-02T17:00:25.000Z","updated_at":"2025-03-06T14:21:36.000Z","dependencies_parsed_at":"2024-06-18T20:06:39.849Z","dependency_job_id":"6742134e-47cc-416e-8ca8-852cb1e27e21","html_url":"https://github.com/dmitry-ivanov/laravel-testing-tools","commit_stats":{"total_commits":596,"total_committers":3,"mean_commits":"198.66666666666666","dds":0.003355704697986628,"last_synced_commit":"e7da2bde80dfca1c38671b1e8cafc31e90b0c63e"},"previous_names":[],"tags_count":88,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-ivanov%2Flaravel-testing-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-ivanov%2Flaravel-testing-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-ivanov%2Flaravel-testing-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitry-ivanov%2Flaravel-testing-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmitry-ivanov","download_url":"https://codeload.github.com/dmitry-ivanov/laravel-testing-tools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280272,"owners_count":20912967,"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":["assertion-functions","assertion-methods","assertions","helpers","laravel","laravel-package","testing","tools"],"created_at":"2024-10-03T12:08:30.276Z","updated_at":"2025-04-05T03:11:36.513Z","avatar_url":"https://github.com/dmitry-ivanov.png","language":"PHP","funding_links":["https://buymeacoffee.com/dmitry.ivanov","https://buymeacoffee.com/dmitry.ivanov)"],"categories":[],"sub_categories":[],"readme":"![Laravel-specific Testing Helpers and Assertions](art/1380x575-optimized.jpg)\n\n# Laravel Testing Tools\n\n[\u003cimg src=\"https://user-images.githubusercontent.com/1286821/181085373-12eee197-187a-4438-90fe-571ac6d68900.png\" alt=\"Buy me a coffee\" width=\"200\" /\u003e](https://buymeacoffee.com/dmitry.ivanov)\n\n[![StyleCI](https://github.styleci.io/repos/75414626/shield?branch=master\u0026style=flat)](https://github.styleci.io/repos/75414626?branch=master)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/dmitry-ivanov/laravel-testing-tools/tests.yml?branch=master)](https://github.com/dmitry-ivanov/laravel-testing-tools/actions?query=workflow%3Atests+branch%3Amaster)\n[![Coverage Status](https://img.shields.io/codecov/c/github/dmitry-ivanov/laravel-testing-tools/master)](https://app.codecov.io/gh/dmitry-ivanov/laravel-testing-tools/tree/master)\n\n![Packagist Version](https://img.shields.io/packagist/v/illuminated/testing-tools)\n![Packagist Stars](https://img.shields.io/packagist/stars/illuminated/testing-tools)\n![Packagist Downloads](https://img.shields.io/packagist/dt/illuminated/testing-tools)\n![Packagist License](https://img.shields.io/packagist/l/illuminated/testing-tools)\n\nLaravel-specific Testing Helpers and Assertions.\n\n| Laravel | Testing Tools                                                            |\n|---------|--------------------------------------------------------------------------|\n| 12.x    | [12.x](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/12.x) |\n| 11.x    | [11.x](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/11.x) |\n| 10.x    | [10.x](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/10.x) |\n| 9.x     | [9.x](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/9.x)   |\n| 8.x     | [8.x](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/8.x)   |\n| 7.x     | [7.x](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/7.x)   |\n| 6.x     | [6.x](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/6.x)   |\n| 5.8.*   | [5.8.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.8) |\n| 5.7.*   | [5.7.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.7) |\n| 5.6.*   | [5.6.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.6) |\n| 5.5.*   | [5.5.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.5) |\n| 5.4.*   | [5.4.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.4) |\n| 5.3.*   | [5.3.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.3) |\n| 5.2.*   | [5.2.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.2) |\n| 5.1.*   | [5.1.*](https://github.com/dmitry-ivanov/laravel-testing-tools/tree/5.1) |\n\n## Usage\n\n1. Install the package via Composer:\n\n    ```shell script\n    composer require --dev illuminated/testing-tools\n    ```\n\n2. Use `Illuminated\\Testing\\TestingTools` trait:\n\n    ```php\n    use Illuminated\\Testing\\TestingTools;\n\n    abstract class TestCase extends Illuminate\\Foundation\\Testing\\TestCase\n    {\n        use TestingTools;\n\n        // ...\n    }\n    ```\n\n3. Use any of the provided helpers and assertions in your tests:\n\n    ```php\n    class ExampleTest extends TestCase\n    {\n        #[Test]\n        public function it_has_lots_of_useful_assertions()\n        {\n            $this-\u003eassertDatabaseHasMany('posts', [\n                ['title' =\u003e 'Awesome!'],\n                ['title' =\u003e 'Check multiple rows'],\n                ['title' =\u003e 'In one simple assertion 🤟'],\n            ]);\n        }\n    }\n    ```\n\n## Available helpers\n\n\u003e Feel free to contribute.\n\n- [ApplicationHelpers](#applicationhelpers)\n  - [emulateLocal](#emulatelocal)\n  - [emulateProduction](#emulateproduction)\n  - [emulateEnvironment](#emulateenvironment)\n\n## Available assertions\n\n\u003e Feel free to contribute.\n\n- [CollectionAsserts](#collectionasserts)\n  - [assertCollectionsEqual](#assertcollectionsequal)\n  - [assertCollectionsNotEqual](#assertcollectionsnotequal)\n- [DatabaseAsserts](#databaseasserts)\n  - [assertDatabaseHasTable](#assertdatabasehastable)\n  - [assertDatabaseMissingTable](#assertdatabasemissingtable)\n  - [assertDatabaseHasMany](#assertdatabasehasmany)\n  - [assertDatabaseMissingMany](#assertdatabasemissingmany)\n- [FilesystemAsserts](#filesystemasserts)\n  - [assertDirectoryEmpty](#assertdirectoryempty)\n  - [assertDirectoryNotEmpty](#assertdirectorynotempty)\n  - [assertFilesCount](#assertfilescount)\n  - [assertNotFilesCount](#assertnotfilescount)\n- [LogFileAsserts](#logfileasserts)\n  - [seeLogFile](#seelogfile)\n  - [dontSeeLogFile](#dontseelogfile)\n  - [seeInLogFile](#seeinlogfile)\n  - [dontSeeInLogFile](#dontseeinlogfile)\n- [ScheduleAsserts](#scheduleasserts)\n  - [seeScheduleCount](#seeschedulecount)\n  - [dontSeeScheduleCount](#dontseeschedulecount)\n  - [seeInSchedule](#seeinschedule)\n  - [dontSeeInSchedule](#dontseeinschedule)\n\n## Helpers\n\n### ApplicationHelpers\n\n#### `emulateLocal()`\n\nEmulate that application is running on the `local` environment:\n\n```php\n$this-\u003eemulateLocal();\n```\n\n#### `emulateProduction()`\n\nEmulate that application is running on the `production` environment:\n\n```php\n$this-\u003eemulateProduction();\n```\n\n#### `emulateEnvironment()`\n\nEmulate that application is running on the given environment:\n\n```php\n$this-\u003eemulateEnvironment('demo');\n```\n\n## Assertions\n\n### CollectionAsserts\n\n#### `assertCollectionsEqual()`\n\nAssert that the given collections are equal based on the specified key:\n\n```php\n$this-\u003eassertCollectionsEqual($collection1, $collection2, 'id');\n```\n\n#### `assertCollectionsNotEqual()`\n\nAssert that the given collections are not equal based on the specified key:\n\n```php\n$this-\u003eassertCollectionsNotEqual($collection1, $collection2, 'id');\n```\n\n### DatabaseAsserts\n\n#### `assertDatabaseHasTable()`\n\nAssert that the database has the given table:\n\n```php\n$this-\u003eassertDatabaseHasTable('users');\n```\n\n#### `assertDatabaseMissingTable()`\n\nAssert that the database doesn't have the given table:\n\n```php\n$this-\u003eassertDatabaseMissingTable('unicorns');\n```\n\n#### `assertDatabaseHasMany()`\n\nAssert that the database has all the given rows:\n\n```php\n$this-\u003eassertDatabaseHasMany('posts', [\n    ['title' =\u003e 'First Post'],\n    ['title' =\u003e 'Second Post'],\n    ['title' =\u003e 'Third Post'],\n]);\n```\n\n#### `assertDatabaseMissingMany()`\n\nAssert that the database doesn't have all the given rows:\n\n```php\n$this-\u003eassertDatabaseMissingMany('posts', [\n    ['title' =\u003e 'Fourth Post'],\n    ['title' =\u003e 'Fifth Post'],\n]);\n```\n\n### FilesystemAsserts\n\n#### `assertDirectoryEmpty()`\n\nAssert that the given directory is empty:\n\n```php\n$this-\u003eassertDirectoryEmpty('./my/dir/');\n```\n\n#### `assertDirectoryNotEmpty()`\n\nAssert that the given directory is not empty:\n\n```php\n$this-\u003eassertDirectoryNotEmpty('./my/dir/');\n```\n\n#### `assertFilesCount()`\n\nAssert that directory has the given number of files:\n\n```php\n$this-\u003eassertFilesCount('./my/dir/', 3);\n```\n\n#### `assertNotFilesCount()`\n\nAssert that directory doesn't have the given number of files:\n\n```php\n$this-\u003eassertNotFilesCount('./my/dir/', 5);\n```\n\n### LogFileAsserts\n\n#### `seeLogFile()`\n\nAssert that the given log file exists.\n\nThe path is relative to the `storage/logs` folder:\n\n```php\n$this-\u003eseeLogFile('example.log');\n```\n\n#### `dontSeeLogFile()`\n\nAssert that the given log file doesn't exist.\n\nThe path is relative to the `storage/logs` folder:\n\n```php\n$this-\u003edontSeeLogFile('foo.log');\n```\n\n#### `seeInLogFile()`\n\nAssert that the log file contains the given message.\n\nThe path is relative to the `storage/logs` folder:\n\n```php\n$this-\u003eseeInLogFile('example.log', 'Sample log message!');\n```\n\nAlso, you can specify an array of messages:\n\n```php\n$this-\u003eseeInLogFile('example.log', [\n    'Sample log message 1!',\n    'Sample log message 2!',\n    'Sample log message 3!',\n]);\n```\n\nYou can use these placeholders in messages:\n- `%datetime%` - any datetime string.\n\n```php\n$this-\u003eseeInLogFile('example.log', '[%datetime%]: Sample log message!');\n```\n\n#### `dontSeeInLogFile()`\n\nAssert that the log file doesn't contain the given message.\n\nThe path is relative to the `storage/logs` folder:\n\n```php\n$this-\u003edontSeeInLogFile('example.log', 'Non-existing log message!');\n```\n\nAlso, you can specify an array of messages:\n\n```php\n$this-\u003edontSeeInLogFile('example.log', [\n    'Non-existing log message 1!',\n    'Non-existing log message 2!',\n    'Non-existing log message 3!',\n]);\n```\n\n### ScheduleAsserts\n\n#### `seeScheduleCount()`\n\nAssert that schedule count equals to the given value:\n\n```php\n$this-\u003eseeScheduleCount(3);\n```\n\n#### `dontSeeScheduleCount()`\n\nAssert that schedule count doesn't equal to the given value:\n\n```php\n$this-\u003edontSeeScheduleCount(5);\n```\n\n#### `seeInSchedule()`\n\nAssert that the given command is scheduled:\n\n```php\n$this-\u003eseeInSchedule('foo', 'everyFiveMinutes');\n$this-\u003eseeInSchedule('bar', 'hourly');\n$this-\u003eseeInSchedule('baz', 'twiceDaily');\n```\n\nAlso, you can use cron expressions:\n\n```php\n$this-\u003eseeInSchedule('foo', '*/5 * * * * *');\n$this-\u003eseeInSchedule('bar', '0 * * * * *');\n$this-\u003eseeInSchedule('baz', '0 1,13 * * * *');\n```\n\n#### `dontSeeInSchedule()`\n\nAssert that the given command is not scheduled:\n\n```php\n$this-\u003edontSeeInSchedule('foo');\n```\n\n## Sponsors\n\n[![Laravel Idea](art/sponsor-laravel-idea.png)](https://laravel-idea.com)\u003cbr\u003e\n[![Material Theme UI Plugin](art/sponsor-material-theme.png)](https://material-theme.com)\u003cbr\u003e\n\n## License\n\nLaravel Testing Tools is open-sourced software licensed under the [MIT license](LICENSE.md).\n\n[\u003cimg src=\"https://user-images.githubusercontent.com/1286821/181085373-12eee197-187a-4438-90fe-571ac6d68900.png\" alt=\"Buy me a coffee\" width=\"200\" /\u003e](https://buymeacoffee.com/dmitry.ivanov)\u0026nbsp;\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitry-ivanov%2Flaravel-testing-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmitry-ivanov%2Flaravel-testing-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitry-ivanov%2Flaravel-testing-tools/lists"}