本文整理汇总了PHP中PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass方法的具体用法?PHP PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass怎么用?PHP PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_MockObject_Generator
的用法示例。
在下文中一共展示了PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: make
public static function make($class, $params = array())
{
if (!class_exists($class)) {
throw new \RuntimeException("Stubbed class {$class} doesn't exist. Use Stub::factory instead");
}
$reflection = new \ReflectionClass($class);
$callables = array_filter($params, function ($a) {
return is_callable($a);
});
if (!empty($callables)) {
if ($reflection->isAbstract()) {
$mock = \PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($class, array_keys($callables), '', false);
} else {
$mock = \PHPUnit_Framework_MockObject_Generator::getMock($class, array_keys($callables), array(), '', false);
}
} else {
if ($reflection->isAbstract()) {
$mock = \PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($class, null, '', false);
} else {
$mock = \PHPUnit_Framework_MockObject_Generator::getMock($class, null, array(), '', false);
}
}
self::bindParameters($mock, $params);
$mock->__mocked = $class;
return $mock;
}
示例2: testGetMockForAbstractClassAnstractClassDoesNotExist
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
* @expectedException PHPUnit_Framework_Exception
*/
public function testGetMockForAbstractClassAnstractClassDoesNotExist()
{
$mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Tux');
}
示例3: getMockForAbstractClass
/**
* Returns a mock object for the specified abstract class with all abstract
* methods of the class mocked. Concrete methods to mock can be specified with
* the last parameter
*
* @param string $originalClassName
* @param array $arguments
* @param string $mockClassName
* @param boolean $callOriginalConstructor
* @param boolean $callOriginalClone
* @param boolean $callAutoload
* @param array $mockedMethods
* @param boolean $cloneArguments
* @return PHPUnit_Framework_MockObject_MockObject
* @since Method available since Release 3.4.0
* @throws PHPUnit_Framework_Exception
*/
public function getMockForAbstractClass($originalClassName, array $arguments = array(), $mockClassName = '', $callOriginalConstructor = TRUE, $callOriginalClone = TRUE, $callAutoload = TRUE, $mockedMethods = array(), $cloneArguments = FALSE)
{
$mockObject = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($originalClassName, $arguments, $mockClassName, $callOriginalConstructor, $callOriginalClone, $callAutoload, $mockedMethods, $cloneArguments);
$this->mockObjects[] = $mockObject;
return $mockObject;
}
示例4: testGetMockForAbstractClassAbstractClassDoesNotExist
/**
* @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
* @expectedException PHPUnit_Framework_MockObject_RuntimeException
*/
public function testGetMockForAbstractClassAbstractClassDoesNotExist()
{
$mock = $this->generator->getMockForAbstractClass('Tux');
}
示例5: getMockForAbstractClass
/**
* Creates a mock object for an abstract class using a fluent interface.
*
* @return PHPUnit_Framework_MockObject_MockObject
*/
public function getMockForAbstractClass()
{
$object = $this->generator->getMockForAbstractClass($this->type, $this->constructorArgs, $this->mockClassName, $this->originalConstructor, $this->originalClone, $this->autoload, $this->methods, $this->cloneArguments);
$this->testCase->registerMockObject($object);
return $object;
}
示例6: getMockForAbstractClass
/**
* @param $className
* @return PHPUnit_Framework_MockObject_MockObject
*/
function getMockForAbstractClass($className)
{
return PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($className);
}
示例7: getMockCustomPlaceholder
/**
* @param $placeholderName
* @return \PHPUnit_Framework_MockObject_MockObject | PlaceholderAbstract
*/
public static function getMockCustomPlaceholder($placeholderName)
{
$myPlaceholder = \PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('\\DbEasy\\Placeholder\\PlaceholderAbstract', [], '', true, true, true, ['getName']);
$myPlaceholder->expects(\PHPUnit_Framework_TestCase::any())->method('getName')->will(\PHPUnit_Framework_TestCase::returnValue($placeholderName));
$myPlaceholder->expects(\PHPUnit_Framework_TestCase::any())->method('transformValue')->will(\PHPUnit_Framework_TestCase::returnCallback(function ($value) {
if ($value === 'in1') {
return 'out1';
}
if ($value === 'in2') {
return 'out2';
}
if ($value === 'in3') {
return 'out3';
}
if ($value === 'in4') {
return 'out4';
}
if ($value === true) {
return true;
}
if ($value === false) {
return false;
}
if ($value === 0) {
return 0;
}
if ($value === '') {
return '';
}
if ($value === 'skip_me_please') {
return Database::SKIP_VALUE;
}
}));
$myPlaceholder->expects(\PHPUnit_Framework_TestCase::any())->method('transformPlaceholder')->will(\PHPUnit_Framework_TestCase::returnCallback(function ($value, $nativePlaceholder) {
if (!empty($nativePlaceholder)) {
if ($value === 'skip_me_please') {
return "SQL_PART_WITHOUT_PARAMS";
}
return $nativePlaceholder;
}
if ($value === 'in1') {
return '"out1"';
}
if ($value === 'in2') {
return '"out2"';
}
if ($value === 'in3') {
return '"out3"';
}
if ($value === 'in4') {
return '"out4"';
}
if ($value === true) {
return 'TRUE';
}
if ($value === false) {
return 'FALSE';
}
if ($value === 0) {
return '0';
}
if ($value === '') {
return '""';
}
}));
return $myPlaceholder;
}
示例8: buildAlternatingSelector
private static function buildAlternatingSelector()
{
$alternating = true;
$mockGenerator = new \PHPUnit_Framework_MockObject_Generator();
$selector = $mockGenerator->getMockForAbstractClass('Superruzafa\\Settings\\Selector');
$selector->expects(self::any())->method('select')->will(self::returnCallback(function () use(&$alternating) {
return $alternating = !$alternating;
}));
return $selector;
}