mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Get rid of mockery library. Still have some troubles with functional tests for api
This commit is contained in:
28
common/tests/helpers/ExtendedPHPMock.php
Normal file
28
common/tests/helpers/ExtendedPHPMock.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\tests\helpers;
|
||||
|
||||
use phpmock\phpunit\PHPMock;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use ReflectionClass;
|
||||
|
||||
trait ExtendedPHPMock {
|
||||
use PHPMock {
|
||||
getFunctionMock as private getOriginalFunctionMock;
|
||||
defineFunctionMock as private defineOriginalFunctionMock;
|
||||
}
|
||||
|
||||
public function getFunctionMock($namespace, $name): MockObject {
|
||||
return $this->getOriginalFunctionMock(static::getClassNamespace($namespace), $name);
|
||||
}
|
||||
|
||||
public static function defineFunctionMock($namespace, $name) {
|
||||
static::defineOriginalFunctionMock(static::getClassNamespace($namespace), $name);
|
||||
}
|
||||
|
||||
private static function getClassNamespace(string $className): string {
|
||||
return (new ReflectionClass($className))->getNamespaceName();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user