granam/test-with-mockery

Mockery test helper ensuring mocked method exists

2.0.0 2021-02-04 15:43 UTC

This package is auto-updated.

Last update: 2024-10-25 01:40:56 UTC


README

No more mocked non-existing methods after a method name change.

class MyTest extends \Granam\Tests\TestWithMockery {
    
    public function testMyClass() {
        $myClassMock = $this->mockery(Sos::class);
        $myClassMock->expects('saveMe') // saveMe() no more exists and \Granam\Tests\Exceptions\MockingOfNonExistingMethod is thrown
            ->andReturn(true);
    }
}

class Sos {
    
    // renamed previous saveMe()
    public function saveUs(): bool {
        return false;
    }
}

Installation

composer require --dev granam/test-with-mockery