{"id":13828334,"url":"https://github.com/rdohms/phpunit-arraysubset-asserts","last_synced_at":"2025-05-16T17:08:08.216Z","repository":{"id":34178774,"uuid":"171058288","full_name":"rdohms/phpunit-arraysubset-asserts","owner":"rdohms","description":"Provides assertArraySubset for use in PHPunit","archived":false,"fork":false,"pushed_at":"2024-11-22T00:48:53.000Z","size":175,"stargazers_count":138,"open_issues_count":11,"forks_count":27,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-12T15:58:39.005Z","etag":null,"topics":["hacktoberfest","php","phpunit","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rdohms.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-02-16T22:24:07.000Z","updated_at":"2025-03-21T22:53:29.000Z","dependencies_parsed_at":"2024-01-18T05:23:06.931Z","dependency_job_id":"3918f4a2-9b03-4419-8b3c-3eb1ddb9d86d","html_url":"https://github.com/rdohms/phpunit-arraysubset-asserts","commit_stats":{"total_commits":69,"total_committers":11,"mean_commits":"6.2727272727272725","dds":0.5797101449275363,"last_synced_commit":"1aa0d838475b1b3de642aa7ad022fadc1e0f5a75"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fphpunit-arraysubset-asserts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fphpunit-arraysubset-asserts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fphpunit-arraysubset-asserts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rdohms%2Fphpunit-arraysubset-asserts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rdohms","download_url":"https://codeload.github.com/rdohms/phpunit-arraysubset-asserts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254573589,"owners_count":22093731,"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":["hacktoberfest","php","phpunit","phpunit-extension"],"created_at":"2024-08-04T09:02:41.847Z","updated_at":"2025-05-16T17:08:08.191Z","avatar_url":"https://github.com/rdohms.png","language":"PHP","readme":"# PHPUnit AssertArraySubset Extension\n\nIn PHPUnit 8 the function `assertArraySubset` was [deprecated](https://github.com/sebastianbergmann/phpunit/issues/3494). This function was often misunderstood and thus removed, but it still holds true as a very useful tool, hence it was extracted here.\n\n**Disclaimer:**\nThe initial version contained here is copied over from phpunit and is heavily based on the original work by [Márcio Almada](https://github.com/marcioAlmada).\n\n## Installation\n\nSimply use it by importing it with Composer\n\n```\ncomposer require --dev dms/phpunit-arraysubset-asserts\n```\n\n\u003e :bulb: The package can be safely required on PHP 5.4 to current in combination with PHPUnit 4.8.36/5.7.21 to current.\n\u003e\n\u003e When the PHPUnit `assertArraySubset()` method is natively available and not deprecated (PHPUnit 4.x - 7.x),\n\u003e the PHPUnit native functionality will be used.\n\u003e For PHPUnit 8 and higher, the extension will kick in and polyfill the functionality which was removed from PHPUnit.\n\n\n## Usage\n\nYou have two options to use this in your classes: either directly as a static call or as a trait if you wish to keep existing references working.\n\n### Trait use example\n\n```php\n\u003c?php\n\nnamespace Your\\Package\\Tests;\n\nuse DMS\\PHPUnitExtensions\\ArraySubset\\ArraySubsetAsserts;\nuse PHPUnit\\Framework\\TestCase;\n\nfinal class ExampleTest extends TestCase\n{\n    use ArraySubsetAsserts;\n\n    public function testWithTrait(): void\n    {\n        $expectedSubset = ['bar' =\u003e 0];\n\n        $content = ['bar' =\u003e '0'];\n\n        self::assertArraySubset($expectedSubset, $content, true);\n\n        $content = ['foo' =\u003e '1'];\n\n        $this-\u003eassertArraySubset($expectedSubset, $content, true);\n    }\n}\n```\n\n### Static class method example\n\n```php\n\u003c?php\n\nnamespace Your\\Package\\Tests;\n\nuse DMS\\PHPUnitExtensions\\ArraySubset\\Assert;\nuse PHPUnit\\Framework\\TestCase;\n\nfinal class ExampleTest extends TestCase\n{\n    public function testWithDirectCall(): void\n    {\n        $expectedSubset = ['bar' =\u003e 0];\n\n        $content = ['bar' =\u003e '0'];\n\n        Assert::assertArraySubset($expectedSubset, $content, true);\n    }\n}\n```\n","funding_links":[],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdohms%2Fphpunit-arraysubset-asserts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frdohms%2Fphpunit-arraysubset-asserts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frdohms%2Fphpunit-arraysubset-asserts/lists"}