当前位置: 首页>>代码示例>>PHP>>正文


PHP PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass方法代码示例

本文整理汇总了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;
 }
开发者ID:BatVane,项目名称:Codeception,代码行数:26,代码来源:Stub.php

示例2: testGetMockForAbstractClassAnstractClassDoesNotExist

 /**
  * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
  * @expectedException PHPUnit_Framework_Exception
  */
 public function testGetMockForAbstractClassAnstractClassDoesNotExist()
 {
     $mock = PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass('Tux');
 }
开发者ID:jeanCarloMachado,项目名称:challenges,代码行数:8,代码来源:GeneratorTest.php

示例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;
 }
开发者ID:Kapitonova,项目名称:codex,代码行数:23,代码来源:TestCase.php

示例4: testGetMockForAbstractClassAbstractClassDoesNotExist

 /**
  * @covers PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass
  * @expectedException PHPUnit_Framework_MockObject_RuntimeException
  */
 public function testGetMockForAbstractClassAbstractClassDoesNotExist()
 {
     $mock = $this->generator->getMockForAbstractClass('Tux');
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:8,代码来源:GeneratorTest.php

示例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;
 }
开发者ID:thanghexp,项目名称:project,代码行数:11,代码来源:MockBuilder.php

示例6: getMockForAbstractClass

/**
 * @param $className
 * @return PHPUnit_Framework_MockObject_MockObject
 */
function getMockForAbstractClass($className)
{
    return PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass($className);
}
开发者ID:versionpress,项目名称:versionpress,代码行数:8,代码来源:generate-files-and-commit.php

示例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;
 }
开发者ID:dakulov,项目名称:DbEasy,代码行数:71,代码来源:Helper.php

示例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;
 }
开发者ID:superruzafa,项目名称:settings,代码行数:10,代码来源:CollectionTest.php


注:本文中的PHPUnit_Framework_MockObject_Generator::getMockForAbstractClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。