PHPackages                             johnbillion/falsey-assertequals-detector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. johnbillion/falsey-assertequals-detector

ActiveLibrary[Testing &amp; Quality](/categories/testing)

johnbillion/falsey-assertequals-detector
========================================

Detects usage of assertEquals() with falsey values and marks the test as risky.

3.2.0(5y ago)810.0k↑430%3GPL-3.0+PHP

Since Jun 29Pushed 5y ago2 watchersCompare

[ Source](https://github.com/johnbillion/falsey-assertequals-detector)[ Packagist](https://packagist.org/packages/johnbillion/falsey-assertequals-detector)[ Docs](https://github.com/johnbillion/falsey-assertequals-detector/)[ RSS](/packages/johnbillion-falsey-assertequals-detector/feed)WikiDiscussions master Synced yesterday

READMEChangelog (6)Dependencies (1)Versions (7)Used By (3)

Falsey assertEquals Detector
============================

[](#falsey-assertequals-detector)

This package will mark a PHPUnit test as risky if it tests a falsey value with `assertEquals()`.

Why?
----

[](#why)

`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:

```
$expected = false;
$actual   = 0;

assertEquals( $expected, $actual );
```

Instead, `assertSame()` should be used when testing falsey values.

This 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.

Falsey values include:

- An empty array
- An empty string
- Boolean `false`
- Float `0.0`
- Integer `0`
- `null`
- String `'0'`

Installation
------------

[](#installation)

```
composer require --dev johnbillion/falsey-assertequals-detector=^3
```

PHPUnit 7, 8, and 9 are supported.

- For PHPUnit 6 support, use version `^2`.
- For PHPUnit 5 support, use version `^1`.

Usage
-----

[](#usage)

Use the trait in your base test class:

```
 class My_Test extends \PHPUnit\Framework\TestCase {

+    use \FalseyAssertEqualsDetector\Test;
+
     public function testSomethingFalsey() {
         $this->assertEquals( 0, false );
     }
 }
```

Any 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.

Example Output
--------------

[](#example-output)

```
1) test_foo
A falsey value is being used in assertEquals().
Expected type:  string
Expected value: ''
Actual type:    boolean
Actual value:   false

```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~112 days

Recently: every ~140 days

Total

6

Last Release

2002d ago

Major Versions

1.0 → 2.02019-06-29

2.0 → 3.02019-06-29

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/208434?v=4)[John Blackbourn](/maintainers/johnbillion)[@johnbillion](https://github.com/johnbillion)

---

Top Contributors

[![johnbillion](https://avatars.githubusercontent.com/u/208434?v=4)](https://github.com/johnbillion "johnbillion (12 commits)")

---

Tags

code-qualityphpunit

### Embed Badge

![Health badge](/badges/johnbillion-falsey-assertequals-detector/health.svg)

```
[![Health](https://phpackages.com/badges/johnbillion-falsey-assertequals-detector/health.svg)](https://phpackages.com/packages/johnbillion-falsey-assertequals-detector)
```

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k136.1M986](/packages/brianium-paratest)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M342](/packages/drupal-core-dev)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

30314.4k7](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
