{"id":15284038,"url":"https://github.com/codekandis/phpunit","last_synced_at":"2026-06-06T10:01:24.435Z","repository":{"id":56955217,"uuid":"230449688","full_name":"codekandis/phpunit","owner":"codekandis","description":"`codekandis/phpunit` is a library providing an enhanced test case wrapper with additional constraint assertions for `PhpUnit`.","archived":false,"fork":false,"pushed_at":"2026-05-27T15:55:37.000Z","size":433,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-27T17:21:46.678Z","etag":null,"topics":["classes","helper","library","php","phpunit","wrapper"],"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/codekandis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-12-27T13:34:01.000Z","updated_at":"2026-05-27T15:55:39.000Z","dependencies_parsed_at":"2024-02-12T01:26:16.397Z","dependency_job_id":"4cb1674a-27e5-4c12-85b7-6f1f71f81b8e","html_url":"https://github.com/codekandis/phpunit","commit_stats":{"total_commits":20,"total_committers":1,"mean_commits":20.0,"dds":0.0,"last_synced_commit":"be4e757ceff1f4d7859ddb3b612fda013a3a5b10"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/codekandis/phpunit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fphpunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fphpunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fphpunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fphpunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codekandis","download_url":"https://codeload.github.com/codekandis/phpunit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekandis%2Fphpunit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33977371,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-06T02:00:07.033Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["classes","helper","library","php","phpunit","wrapper"],"created_at":"2024-09-30T14:48:53.194Z","updated_at":"2026-06-06T10:01:24.430Z","avatar_url":"https://github.com/codekandis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codekandis/phpunit\n\n[![Version][xtlink-version-badge]][srclink-changelog]\n[![License][xtlink-license-badge]][srclink-license]\n[![Minimum PHP Version][xtlink-php-version-badge]][xtlink-php-net]\n![Code Coverage][xtlink-code-coverage-badge]\n\n`codekandis/phpunit` is a library providing an enhanced test case wrapper with additional constraint assertions for\n[`phpunit/phpunit`][xtlink-packagist-phpunit-phpunit].\n\n## Index\n\n* [Installation](#installation)\n* [Usage](#usage)\n  * [Using the test case wrapper](#using-the-test-case-wrapper)\n  * [Using the data provider interface](#using-the-data-provider-interface)\n  * [Asserting array subsets](#asserting-array-subsets)\n    * [`TestCase::assertArrayContainsKeyedSubset()`](#testcaseassertarraycontainskeyedsubset)\n    * [`TestCase::assertArrayContainsUnkeyedSubset()`](#testcaseassertarraycontainsunkeyedsubset)\n    * [`TestCase::assertIsKeyedSubsetOfArray()`](#testcaseassertiskeyedsubsetofarray)\n    * [`TestCase::assertIsUnkeyedSubsetOfArray()`](#testcaseassertisunkeyedsubsetofarray)\n  * [Asserting subclass relationships](#asserting-subclass-relationships)\n    * [`TestCase::assertIsSubClassOf()`](#testcaseassertissubclassof)\n\n## Installation\n\nInstall the latest version with\n\n```bash\n$ composer require --dev codekandis/phpunit\n```\n\n## Usage\n\n### Using the test case wrapper\n\nCreate a test case that extends the `TestCase` wrapper.\n\nThe additional constraint assertions are available through this wrapper.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\TestCase;\n\nclass ApplicationTest extends TestCase\n{\n}\n```\n\n### Using the data provider interface\n\nCreate a data provider that implements `DataProviderInterface`.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\DataProviderInterface;\nuse Override;\n\nfinal class DifferentValuesDataProvider implements DataProviderInterface\n{\n\t#[Override]\n\tpublic static function provideData(): iterable\n\t{\n\t\treturn [\n\t\t\t0 =\u003e [\n\t\t\t\t23,\n\t\t\t\t42\n\t\t\t],\n\t\t\t1 =\u003e [\n\t\t\t\t'foo',\n\t\t\t\t'bar'\n\t\t\t]\n\t\t];\n\t}\n}\n```\n\nUse the data provider in your test case.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\TestCase;\nuse CodeKandis\\PhpUnit\\DataProviderInterface;\nuse PHPUnit\\Framework\\Attributes\\DataProviderExternal;\n\nfinal class DifferentValuesTest extends TestCase\n{\n\t#[DataProviderExternal( DifferentValuesDataProvider::class, DataProviderInterface::PROVIDER_METHOD_NAME )]\n\tpublic function testValuesAreDifferent( mixed $value1, mixed $value2 ): void\n\t{\n\t\tstatic::assertNotSame( $value1, $value2 );\n\t}\n}\n```\n\n### Asserting array subsets\n\n#### `TestCase::assertArrayContainsKeyedSubset()`\n\nUse `TestCase::assertArrayContainsKeyedSubset()` to assert that `$actualArray` contains `$expectedSubset` with matching\nkeys and values. Set `$strict` to `true` to compare values strictly, or to `false` to compare values loosely.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\TestCase;\n\nfinal class ArrayTest extends TestCase\n{\n\tpublic function testArrayContainsKeyedSubset(): void\n\t{\n\t\tstatic::assertArrayContainsKeyedSubset(\n\t\t\t[\n\t\t\t\t'foo' =\u003e [\n\t\t\t\t\t'bar' =\u003e 23\n\t\t\t\t]\n\t\t\t],\n\t\t\t[\n\t\t\t\t'foo' =\u003e [\n\t\t\t\t\t'bar' =\u003e 23,\n\t\t\t\t\t'baz' =\u003e 42\n\t\t\t\t]\n\t\t\t],\n\t\t\ttrue\n\t\t);\n\t}\n}\n```\n\n#### `TestCase::assertArrayContainsUnkeyedSubset()`\n\nUse `TestCase::assertArrayContainsUnkeyedSubset()` to assert that `$actualArray` contains the values of\n`$expectedSubset` without comparing keys. Set `$strict` to `true` to compare values strictly, or to `false` to compare\nvalues loosely.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\TestCase;\n\nfinal class ArrayTest extends TestCase\n{\n\tpublic function testArrayContainsUnkeyedSubset(): void\n\t{\n\t\tstatic::assertArrayContainsUnkeyedSubset(\n\t\t\t[\n\t\t\t\t23,\n\t\t\t],\n\t\t\t[\n\t\t\t\t42,\n\t\t\t\t23\n\t\t\t],\n\t\t\ttrue\n\t\t);\n\t}\n}\n```\n\n#### `TestCase::assertIsKeyedSubsetOfArray()`\n\nUse `TestCase::assertIsKeyedSubsetOfArray()` to assert that `$actualSubset` is contained in `$expectedArray` with\nmatching keys and values. Set `$strict` to `true` to compare values strictly, or to `false` to compare values loosely.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\TestCase;\n\nfinal class ArrayTest extends TestCase\n{\n\tpublic function testKeyedSubsetIsSubsetOfArray(): void\n\t{\n\t\tstatic::assertIsKeyedSubsetOfArray(\n\t\t\t[\n\t\t\t\t'foo' =\u003e [\n\t\t\t\t\t'bar' =\u003e 23,\n\t\t\t\t\t'baz' =\u003e 42\n\t\t\t\t]\n\t\t\t],\n\t\t\t[\n\t\t\t\t'foo' =\u003e [\n\t\t\t\t\t'bar' =\u003e 23\n\t\t\t\t]\n\t\t\t],\n\t\t\ttrue\n\t\t);\n\t}\n}\n```\n\n#### `TestCase::assertIsUnkeyedSubsetOfArray()`\n\nUse `TestCase::assertIsUnkeyedSubsetOfArray()` to assert that the values of `$actualSubset` are contained in\n`$expectedArray` without comparing keys. Set `$strict` to `true` to compare values strictly, or to `false` to compare\nvalues loosely.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\TestCase;\n\nfinal class ArrayTest extends TestCase\n{\n\tpublic function testUnkeyedSubsetIsSubsetOfArray(): void\n\t{\n\t\tstatic::assertIsUnkeyedSubsetOfArray(\n\t\t\t[\n\t\t\t\t42,\n\t\t\t\t23\n\t\t\t],\n\t\t\t[\n\t\t\t\t23\n\t\t\t],\n\t\t\ttrue\n\t\t);\n\t}\n}\n```\n\n### Asserting subclass relationships\n\n#### `TestCase::assertIsSubClassOf()`\n\nUse `TestCase::assertIsSubClassOf()` to assert that `$actual` is a subclass of or implements\n`$expectedInterfaceOrClassName`. `$actual` can be an object or a class name.\n\n```php\n\u003c?php declare( strict_types = 1 );\nnamespace Vendor\\Project\\Tests;\n\nuse CodeKandis\\PhpUnit\\TestCase;\n\ninterface MessageHandlerInterface\n{\n}\n\nfinal class MessageHandler implements MessageHandlerInterface\n{\n}\n\nfinal class MessageHandlerTest extends TestCase\n{\n\tpublic function testMessageHandlerImplementsMessageHandlerInterface(): void\n\t{\n\t\tstatic::assertIsSubClassOf(\n\t\t\tMessageHandlerInterface::class,\n\t\t\tMessageHandler::class\n\t\t);\n\t}\n}\n```\n\nThe assertion throws an `UnknownClassOrInterfaceException` if the expected type does not exist.\n\n\n\n[xtlink-version-badge]: https://img.shields.io/badge/version-5.0.0-blue.svg\n[xtlink-license-badge]: https://img.shields.io/badge/license-MIT-yellow.svg\n[xtlink-php-version-badge]: https://img.shields.io/badge/php-%3E%3D%208.5-8892BF.svg\n[xtlink-code-coverage-badge]: https://img.shields.io/badge/coverage-100%25-green.svg\n[xtlink-php-net]: https://php.net\n[xtlink-packagist-phpunit-phpunit]: https://packagist.org/packages/phpunit/phpunit\n\n[srclink-changelog]: ./CHANGELOG.md\n[srclink-license]: ./LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekandis%2Fphpunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodekandis%2Fphpunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekandis%2Fphpunit/lists"}