{"id":15014525,"url":"https://github.com/vladahejda/phpunitassertexception","last_synced_at":"2025-04-12T08:08:40.436Z","repository":{"id":57078481,"uuid":"44783444","full_name":"VladaHejda/PhpUnitAssertException","owner":"VladaHejda","description":"Assert exception/throwable/error PHPUnit trait","archived":false,"fork":false,"pushed_at":"2018-03-23T12:48:37.000Z","size":37,"stargazers_count":18,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T08:05:27.173Z","etag":null,"topics":["php","phpunit","phpunit-assertions","phpunit-extension"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VladaHejda.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-23T01:30:26.000Z","updated_at":"2022-05-06T05:37:42.000Z","dependencies_parsed_at":"2022-08-24T13:10:09.539Z","dependency_job_id":null,"html_url":"https://github.com/VladaHejda/PhpUnitAssertException","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladaHejda%2FPhpUnitAssertException","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladaHejda%2FPhpUnitAssertException/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladaHejda%2FPhpUnitAssertException/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VladaHejda%2FPhpUnitAssertException/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VladaHejda","download_url":"https://codeload.github.com/VladaHejda/PhpUnitAssertException/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537137,"owners_count":21120709,"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":["php","phpunit","phpunit-assertions","phpunit-extension"],"created_at":"2024-09-24T19:45:43.838Z","updated_at":"2025-04-12T08:08:40.412Z","avatar_url":"https://github.com/VladaHejda.png","language":"PHP","readme":"# PhpUnitAssertException\n\n`AssertException` is a trait, so it can be easily used in your test case.\n\n- For PHP 7.1 and PHPUnit 6 compatibility require version `1.3`.\n- For PHP 7.1 compatibility require version `1.2`.\n- For PHP 7 compatibility require version `1.1`.\n- For PHP 5 compatibility require version `1.0`.\n\n## Install\n\n```\n$ composer require vladahejda/phpunit-assert-exception\n```\n\n\n## Usage\n\n```php\n\u003c?php\n\nclass MyTest extends \\PHPUnit\\Framework\\TestCase\n{\n\tuse VladaHejda\\AssertException;\n\n\tpublic function testMultipleExceptionsAtOnce()\n\t{\n\t\t$test = function () {\n\t\t\t// here comes some test stuff of your unit (tested class)\n\t\t\t// which you expect that will throw an Exception\n\t\t\tthrow new InvalidArgumentException('Some message 12345', 100);\n\t\t};\n\n\t\t// just test if function throws an Exception\n\t\t$this-\u003eassertException($test); // pass\n\n\t\t// test class of an Exception\n\t\t$this-\u003eassertException($test, InvalidArgumentException::class); // pass\n\n\t\t// test Exception code\n\t\t$this-\u003eassertException($test, null, 100); // pass\n\n\t\t// test Exception message\n\t\t$this-\u003eassertException($test, null, null, 'Some message 12345'); // pass\n\t\t$this-\u003eassertException($test, null, null, 'Some message'); // also pass, because it checks on substring level\n\n\t\t// test all\n\t\t$this-\u003eassertException($test, InvalidArgumentException::class, 100, 'Some message 12345'); // pass\n\n\t\t// and here some failing tests\n\t\t// wrong class\n\t\t$this-\u003eassertException($test, ErrorException::class); // fail\n\t\t// wrong code\n\t\t$this-\u003eassertException($test, InvalidArgumentException::class, 200); // fail\n\t\t// wrong message\n\t\t$this-\u003eassertException($test, InvalidArgumentException::class, 100, 'Bad message'); // fail\n\t}\n}\n```\n\nAlso see an `assertError` and `assertThrowable` methods, which tests if PHP internal `Error` was thrown, or any `Throwable` respectively.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladahejda%2Fphpunitassertexception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladahejda%2Fphpunitassertexception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladahejda%2Fphpunitassertexception/lists"}