# PHPUnit Enhancement Plugin Inspections

**Inspections** highlight invalid, inaccessible, deprecated, or legacy mocked method usages in PHPUnit and Mockery tests.

---

## Mocked method usage highlighting

**Feature ID:** `MockedMethodStringAnnotators`  
**Feature Page:** [Mocked method usage highlighting](https://espend.de/phpstorm/plugin/phpunit#mocked-method-string-annotators)  

Highlights method strings that cannot be resolved against the mocked class. PHPUnit and Mockery strings warn when the target method is missing; Mockery also warns for private methods and discourages protected method mocking.

### Code Examples

```php
# Warnings for unknown or inaccessible mocked methods:
$gateway = $this->createMock(PaymentGateway::class);
$gateway->method('missingMethod');

$repository = \Mockery::mock(UserRepository::class);
$repository->expects('privateMethod');
$repository->allows('protectedMethod');
```

---

## Deprecated mocked method inspection

**Feature ID:** `DeprecatedMockedMethodInspection`  
**Feature Page:** [Deprecated mocked method inspection](https://espend.de/phpstorm/plugin/phpunit#deprecated-mocked-method-inspection)  

Reports mocked method strings that point to deprecated class methods. The inspection covers both normal PHPUnit `method()` mocks and `createPartialMock()` method arrays.

### Code Examples

```php
# Deprecated method used by PHPUnit mocks:
final class PaymentGateway
{
    /** @deprecated use authorize() */
    public function capture(): bool
    {
        return true;
    }
}

$gateway = $this->createMock(PaymentGateway::class);
$gateway->method('capture');

$partial = $this->createPartialMock(PaymentGateway::class, ['capture']);
```

---

## Replace legacy Mockery syntax

**Feature ID:** `ReplaceLegacyMockeryInspection`  
**Feature Page:** [Replace legacy Mockery syntax](https://espend.de/phpstorm/plugin/phpunit#replace-legacy-mockery-inspection)  

Detects legacy `shouldReceive()` and `shouldNotReceive()` chains and offers a quick fix to convert them to modern Mockery syntax. The inspection can prefer array notation, multiple statements, string notation, or fluent `allows()->method()` notation.

### Code Examples

```php
# Legacy shouldReceive() converted to allows():
$repository->shouldReceive('find')->with(42)->andReturn($user);
$repository->allows('find')->with(42)->andReturns($user);
```

```php
# once() expectations become expects():
$repository->shouldReceive('save')->once();
$repository->expects('save');
```

```php
# Optional fluent Mockery target style:
$repository->shouldReceive('find')->with(42)->andReturn($user);
$repository->allows()->find(42)->andReturns($user);
```

---

