2017-09-19 22:36:16 +05:30
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
2019-06-18 05:03:20 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace common\tests\helpers;
|
2017-09-19 22:36:16 +05:30
|
|
|
|
|
|
|
use phpmock\mockery\PHPMockery;
|
|
|
|
use ReflectionClass;
|
|
|
|
|
|
|
|
class Mock {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $className
|
|
|
|
* @param string $function
|
|
|
|
*
|
|
|
|
* @return \Mockery\Expectation
|
|
|
|
*/
|
|
|
|
public static function func(string $className, string $function) {
|
|
|
|
return PHPMockery::mock(self::getClassNamespace($className), $function);
|
|
|
|
}
|
|
|
|
|
2019-06-18 05:03:20 +05:30
|
|
|
public static function define(string $className, string $function): void {
|
|
|
|
PHPMockery::define(self::getClassNamespace($className), $function);
|
|
|
|
}
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
private static function getClassNamespace(string $className): string {
|
|
|
|
return (new ReflectionClass($className))->getNamespaceName();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|