---
title: "lint/phpunit/add-data-provider-allow-mock-objects"
pagination: false
---

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

<RuleId id="lint/phpunit/add-data-provider-allow-mock-objects" />

Not in any set. Safe fix. Runs when phpunit is installed.

## What it does

Add #[AllowMockObjectsWithoutExpectations] attribute to PHPUnit test classes that have methods with data providers and mock objects without expectations

## Configuration

```toml title="pun.toml"
[lint.rules]
"phpunit/add-data-provider-allow-mock-objects" = "error"
```

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

## Replaces

- [`AllowMockObjectsForDataProvider`](https://getrector.com/rule-detail/allow-mock-objects-for-data-provider-rector) (rector-phpunit)

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