# PHPUnit Enhancement Plugin Completion

**Completion** features provide context-aware suggestions for PHPUnit mock methods, `createPartialMock()` arrays, Mockery expectation strings, and generated partial mock declarations.

---

## PHPUnit mock method completion

**Feature ID:** `PhpUnitMockMethodCompletion`  
**Feature Page:** [PHPUnit mock method completion](https://espend.de/phpstorm/plugin/phpunit#php-unit-mock-method-completion)  

Completes mocked class methods inside PHPUnit mock API strings. The plugin resolves the mocked class from `createMock()`, `getMockBuilder()->getMock()`, legacy `getMock()`, `getMockForAbstractClass()`, `getMockForTrait()`, and invocation mocker `method()` calls.

### Code Examples

```php
# Completion inside method():
class InvoiceServiceTest extends \PHPUnit\Framework\TestCase
{
    public function testTotal(): void
    {
        $gateway = $this->createMock(PaymentGateway::class);
        $gateway->method('<caret>')->willReturn(true);
    }
}
```

```php
# Completion after getMockBuilder():
$gateway = $this->getMockBuilder(PaymentGateway::class)
    ->disableOriginalConstructor()
    ->getMock();

$gateway->method('<caret>')->willReturn(true);
```

---

## createPartialMock method list completion

**Feature ID:** `PhpUnitCreatePartialMockCompletion`  
**Feature Page:** [createPartialMock method list completion](https://espend.de/phpstorm/plugin/phpunit#php-unit-create-partial-mock-completion)  

Completes method names in the second argument of `createPartialMock()`. The same reference target is reused for navigation and rename support, so partial mocks stay connected to the original class methods.

### Code Examples

```php
# Partial mock method array:
class ReportBuilderTest extends \PHPUnit\Framework\TestCase
{
    public function testPartial(): void
    {
        $builder = $this->createPartialMock(ReportBuilder::class, ['<caret>']);
        $builder->method('build')->willReturn('ready');
    }
}
```

---

## Mockery method string completion

**Feature ID:** `MockeryMethodStringCompletion`  
**Feature Page:** [Mockery method string completion](https://espend.de/phpstorm/plugin/phpunit#mockery-method-string-completion)  

Completes method strings for Mockery expectations in `allows()`, `expects()`, `shouldReceive()`, `shouldNotReceive()`, `shouldHaveReceived()`, `shouldNotHaveReceived()`, array syntax, and generated partial mock declarations.

### Code Examples

```php
# Expectation method strings:
$repository = \Mockery::mock(UserRepository::class);
$repository->allows('<caret>')->andReturns($user);
$repository->expects('<caret>')->once();
```

```php
# Array and generated partial syntax:
$repository->shouldReceive(['find' => $user, '<caret>' => []]);

$partial = \Mockery::mock(UserRepository::class . '[<caret>]');
```

---

