---
title: "lint/phpunit/prefer-assert-same"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/phpunit/prefer-assert-same" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Unsafe fix: it can change behaviour. Runs when phpunit is installed.

## What it does

PHPUnit methods like `assertSame` should be used instead of `assertEquals`.

## Configuration

```toml title="pun.toml"
[lint.rules]
"phpunit/prefer-assert-same" = "error"
```

To skip it in some files, add an [override](/docs/configuration/pun-toml#lint) or a [`@pun-ignore-file`](/docs/configuration/ignore-comments) comment.

## Options

| Name | Type | Allowed values | Default | Upstream name |
| --- | --- | --- | --- | --- |
| `assertions` | `list` | `assertAttributeEquals`, `assertAttributeNotEquals`, `assertEquals`, `assertNotEquals` | `["assertAttributeEquals", "assertAttributeNotEquals", "assertEquals", "assertNotEquals"]` | `assertions` |

## Replaces

- [`php_unit_strict`](https://cs.symfony.com/doc/rules/php_unit/php_unit_strict.html) (php-cs-fixer, risky)
- [`AssertEqualsToSame`](https://getrector.com/rule-detail/assert-equals-to-same-rector) (rector-phpunit)
- [`strict-assertions`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#strict-assertions) (mago-linter)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/phpunit/prefer-same-for-scalars`

[More lint/phpunit rules](/docs/rules/lint/phpunit) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
