{"id":15008362,"url":"https://github.com/webmozarts/strict-phpunit","last_synced_at":"2025-04-07T07:07:00.865Z","repository":{"id":62548055,"uuid":"355611933","full_name":"webmozarts/strict-phpunit","owner":"webmozarts","description":"Enables type-safe comparisons of objects in PHPUnit.","archived":false,"fork":false,"pushed_at":"2025-03-25T10:38:17.000Z","size":141,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-04-05T20:49:15.384Z","etag":null,"topics":["phpunit","strict-types"],"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/webmozarts.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-04-07T16:25:51.000Z","updated_at":"2025-03-24T18:57:42.000Z","dependencies_parsed_at":"2024-03-15T15:31:25.276Z","dependency_job_id":"00b772f8-1e86-4c13-a280-26cb6f3a57bf","html_url":"https://github.com/webmozarts/strict-phpunit","commit_stats":{"total_commits":11,"total_committers":3,"mean_commits":"3.6666666666666665","dds":"0.18181818181818177","last_synced_commit":"f107d155d3838accdc5f1afe8b93d284a7ea3ce7"},"previous_names":[],"tags_count":80,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webmozarts%2Fstrict-phpunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webmozarts%2Fstrict-phpunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webmozarts%2Fstrict-phpunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webmozarts%2Fstrict-phpunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webmozarts","download_url":"https://codeload.github.com/webmozarts/strict-phpunit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247608151,"owners_count":20965952,"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","strict-types"],"created_at":"2024-09-24T19:17:50.737Z","updated_at":"2025-04-07T07:07:00.839Z","avatar_url":"https://github.com/webmozarts.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Strict PHPUnit\n\nEnables type-safe comparisons of objects in PHPUnit.\n\n## Problem\n\nPHPUnit has a very powerful comparison system that helps you comparing objects\nwith expected values:\n\n```php\nclass ValueObject\n{\n    public ?string $property;\n    \n    public function __construct(?string $property)\n    {\n        $this-\u003eproperty = $property;\n    }\n}\n\n$actual = new ValueObject('foo!');\n\nself::assertEquals(new ValueObject('foo'), $actual);\n// =\u003e fails with a very helpful error message\n```\n\nThis comparison system will give you a meaningful exception that guides you\nprecisely to the problem that caused the assertion to fail. Strings are\nfurthermore diffed so that you see exactly which character of the string\ncauses a mismatch.\n\nPHPUnit compares each scalar property of an object with relaxed types. It is a \nlittle more intelligent than using just `==` under the hood, but still that\nwill not always provide the results you want:\n\n```php\nvar_dump('Hi' == true);\n// =\u003e true\n\nself::assertEquals(new ValueObject('Hi'), new ValueObject(true));\n// =\u003e fails\n\nvar_dump('' == null);\n// =\u003e true\n\nself::assertEquals(new ValueObject(''), new ValueObject(null));\n// =\u003e succeeds\n```\n\n## Solution\n\nThis extension enables a comparator for scalar values that fights this problem.\nWith this extension, whenever PHPUnit finds a scalar value during \n`assertEquals()` (even recursively within objects or arrays), it will compare\nthe value with `===`.\n\nObjects are still not checked for identity, hence you can still construct\nexample objects to compare against.\n\nError messages stay meaningful.\n\n```php\nself::assertEquals(new ValueObject(''), new ValueObject(null));\n// =\u003e fails with a meaningful error\n\nself::assertEquals(new ValueObject('foo!'), new ValueObject('foo'));\n// =\u003e fails with a meaningful error\n\nself::assertEquals(new ValueObject('foo!'), new ValueObject('foo!'));\n// =\u003e succeeds\n```\n\n## Installation\n\nThe extension can be installed with Composer:\n\n```bash\n$ composer require --dev webmozarts/strict-phpunit\n```\n\nAdd the extension to your `phpunit.xml.dist` file to enable it:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cphpunit xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n         xsi:noNamespaceSchemaLocation=\"vendor/phpunit/phpunit/phpunit.xsd\"\u003e\n    \u003c!-- ... --\u003e\n    \n    \u003cextensions\u003e\n        \u003cextension class=\"Webmozarts\\StrictPHPUnit\\StrictPHPUnitExtension\"/\u003e\n    \u003c/extensions\u003e\n    \n    \u003c!-- ... --\u003e\n\u003c/phpunit\u003e\n```\n\n## Authors\n\n* [Bernhard Schussek]\n* [The Community Contributors]\n\n## Contribute\n\nContributions to the package are always welcome!\n\n* Report any bugs or issues you find on the [issue tracker].\n* You can grab the source code at the package's [Git repository].\n\nNote that this repository is a subtree-split of a monorepo and hence read only.\nPRs will be ported to the (internal) monorepo.\n\nLicense\n-------\n\nAll contents of this package are licensed under the [MIT license].\n\n[Composer]: https://getcomposer.org\n[Bernhard Schussek]: http://webmozarts.com\n[The Community Contributors]: https://github.com/webmozarts/strict-phpunit/graphs/contributors\n[issue tracker]: https://github.com/webmozarts/strict-phpunit/issues\n[Git repository]: https://github.com/webmozarts/strict-phpunit\n[MIT license]: LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebmozarts%2Fstrict-phpunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebmozarts%2Fstrict-phpunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebmozarts%2Fstrict-phpunit/lists"}