granam/test-with-mockery

Mockery 测试辅助器,确保存在模拟方法

2.0.0 2021-02-04 15:43 UTC

This package is auto-updated.

Last update: 2024-08-25 01:21:25 UTC


README

方法名更改后不再有非存在的模拟方法。

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;
    }
}

安装

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