1
0
Fork 0
mirror of synced 2025-04-04 05:33:31 +03:00

update TestCase

This commit is contained in:
Akolzin Dmitry 2020-04-08 16:46:30 +03:00 committed by gorokh
parent cc3a6f9f08
commit 1ef8318bb8

View file

@ -13,14 +13,27 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase
{
if (method_exists(\PHPUnit\Framework\TestCase::class, 'createMock')) {
return parent::createMock($originalClassName);
} elseif (method_exists(\PHPUnit\Framework\TestCase::class, 'getMock')) {
} else {
return $this->getMockBuilder($originalClassName)
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->getMock();
}
}
protected function createPartialMock($originalClassName, $methods)
{
if (method_exists(\PHPUnit\Framework\TestCase::class, 'createPartialMock')) {
return parent::createMock($originalClassName);
} else {
throw new \RuntimeException('Not supported phpunit version');
return $this->getMockBuilder($originalClassName)
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
// ->disallowMockingUnknownTypes()
->setMethods(empty($methods) ? null : $methods)
->getMock();
}
}
}