{"id":25652986,"url":"https://github.com/devlop/phpunit-exception-assertions","last_synced_at":"2025-02-23T19:18:36.626Z","repository":{"id":56966807,"uuid":"341156930","full_name":"devlop/phpunit-exception-assertions","owner":"devlop","description":"PHPUnit assertions for exceptions.","archived":false,"fork":false,"pushed_at":"2021-03-05T08:42:39.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-11T20:13:44.868Z","etag":null,"topics":["phpunit","phpunit-assertions"],"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/devlop.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}},"created_at":"2021-02-22T10:09:39.000Z","updated_at":"2021-03-05T08:42:42.000Z","dependencies_parsed_at":"2022-08-21T11:20:26.388Z","dependency_job_id":null,"html_url":"https://github.com/devlop/phpunit-exception-assertions","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fphpunit-exception-assertions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fphpunit-exception-assertions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fphpunit-exception-assertions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fphpunit-exception-assertions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devlop","download_url":"https://codeload.github.com/devlop/phpunit-exception-assertions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240280864,"owners_count":19776414,"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":["phpunit","phpunit-assertions"],"created_at":"2025-02-23T19:18:36.045Z","updated_at":"2025-02-23T19:18:36.594Z","avatar_url":"https://github.com/devlop.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/devlop/phpunit-exception-assertions\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/devlop/phpunit-exception-assertions\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/devlop/phpunit-exception-assertions/blob/master/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/devlop/phpunit-exception-assertions\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# PHPUnit Exception Assertions\n\nTrait containing assertions for easier testing of thrown (or not thrown) exceptions.\n\n# Installation\n\n```bash\ncomposer require --dev devlop/phpunit-exception-assertions\n```\n\n# Usage\n\nInclude the trait to get access to the assertions.\n\n```php\nuse Devlop\\PHPUnit\\ExceptionAssertions;\n\nclass YourTest extends TestCase\n{\n    use ExceptionAssertions;\n}\n```\n\n# Available Assertions\n\n## assertExceptionThrown\n\nAsserts that a specific exception was thrown during the execution of the callback,\nif the callback finishes without the exception being thrown, the assertion fails.\n\nTo check for any exception, use `\\Throwable::class` as first argument since all exceptions inherits from [`\\Throwable`](https://www.php.net/manual/en/class.throwable.php).\n\n```php\n$this-\u003eassertExceptionThrown(\\InvalidArgumentException::class, function () : void {\n    // code that should throw the expected exception\n});\n```\n\n## assertExceptionNotThrown\n\nAsserts that a specific exception was not thrown during the execution of the callback,\nif the specified exception was thrown during execution the assertion fails.\n\n**use with caution** - this will only assert that a specific exception was not thrown and\nthe assertion will pass for any other exceptions thrown, intentional or accidental.\nIn most cases it is probably better to `assertNoExceptionsThrown` instead.\n\n```php\n$this-\u003eassertExceptionNotThrown(\\InvalidArgumentException::class, function () : void {\n    // code that should not throw the exception\n});\n```\n\n## assertNoExceptionsThrown\n\nAsserts that no exceptions was thrown during the execution of the callback,\nif any exceptions was thrown during the execution the assertion fails.\n\n```php\n$this-\u003eassertNoExceptionsThrown(function () : void {\n    // code that should not throw any exceptions\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlop%2Fphpunit-exception-assertions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevlop%2Fphpunit-exception-assertions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlop%2Fphpunit-exception-assertions/lists"}