{"id":15014554,"url":"https://github.com/johnbillion/falsey-assertequals-detector","last_synced_at":"2025-04-12T08:08:49.685Z","repository":{"id":57000859,"uuid":"194425216","full_name":"johnbillion/falsey-assertequals-detector","owner":"johnbillion","description":"Marks a PHPUnit test as risky if it tests a falsey value with assertEquals()","archived":false,"fork":false,"pushed_at":"2021-01-08T12:32:16.000Z","size":18,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T08:06:58.996Z","etag":null,"topics":["code-quality","phpunit"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/johnbillion/falsey-assertequals-detector","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnbillion.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}},"created_at":"2019-06-29T16:15:38.000Z","updated_at":"2023-02-13T16:16:41.000Z","dependencies_parsed_at":"2022-08-21T14:10:25.704Z","dependency_job_id":null,"html_url":"https://github.com/johnbillion/falsey-assertequals-detector","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Ffalsey-assertequals-detector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Ffalsey-assertequals-detector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Ffalsey-assertequals-detector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnbillion%2Ffalsey-assertequals-detector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnbillion","download_url":"https://codeload.github.com/johnbillion/falsey-assertequals-detector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537136,"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":["code-quality","phpunit"],"created_at":"2024-09-24T19:45:45.950Z","updated_at":"2025-04-12T08:08:49.644Z","avatar_url":"https://github.com/johnbillion.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Falsey assertEquals Detector\n\nThis package will mark a PHPUnit test as risky if it tests a falsey value with `assertEquals()`.\n\n## Why?\n\n`assertEquals()` isn't type sensitive which means checking falsey values with it can result in tests passing when they shouldn't. For example, this assertion passes but it's probably unexpected:\n\n```php\n$expected = false;\n$actual   = 0;\n\nassertEquals( $expected, $actual );\n```\n\nInstead, `assertSame()` should be used when testing falsey values.\n\nThis package will mark a test as risky if it tests a falsey value with `assertEquals()` so that you can investigate the test and improve its assertions as necessary.\n\nFalsey values include:\n\n* An empty array\n* An empty string\n* Boolean `false`\n* Float `0.0`\n* Integer `0`\n* `null`\n* String `'0'`\n\n## Installation\n\n```shell\ncomposer require --dev johnbillion/falsey-assertequals-detector=^3\n```\n\nPHPUnit 7, 8, and 9 are supported.\n\n* For PHPUnit 6 support, use version `^2`.\n* For PHPUnit 5 support, use version `^1`.\n\n## Usage\n\nUse the trait in your base test class:\n\n```diff\n class My_Test extends \\PHPUnit\\Framework\\TestCase {\n \n+    use \\FalseyAssertEqualsDetector\\Test;\n+\n     public function testSomethingFalsey() {\n         $this-\u003eassertEquals( 0, false );\n     }\n }\n```\n\nAny time one of your tests calls `assertEquals()`, the test will be marked as risky if either the expected value or the actual value are falsey.\n\n## Example Output\n\n```\n1) test_foo\nA falsey value is being used in assertEquals().\nExpected type:  string\nExpected value: ''\nActual type:    boolean\nActual value:   false\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbillion%2Ffalsey-assertequals-detector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnbillion%2Ffalsey-assertequals-detector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnbillion%2Ffalsey-assertequals-detector/lists"}