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


PHP PHPUnit_Framework_TestCase::getMockForAbstractClass方法代码示例

本文整理汇总了PHP中PHPUnit_Framework_TestCase::getMockForAbstractClass方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestCase::getMockForAbstractClass方法的具体用法?PHP PHPUnit_Framework_TestCase::getMockForAbstractClass怎么用?PHP PHPUnit_Framework_TestCase::getMockForAbstractClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PHPUnit_Framework_TestCase的用法示例。


在下文中一共展示了PHPUnit_Framework_TestCase::getMockForAbstractClass方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getLayoutUpdateFromFixture

 /**
  * Retrieve new layout update model instance with XML data from a fixture file
  *
  * @param string|array $layoutUpdatesFile
  * @return \Magento\Framework\View\Layout\ProcessorInterface
  */
 public function getLayoutUpdateFromFixture($layoutUpdatesFile)
 {
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     /** @var \Magento\Framework\View\File\Factory $fileFactory */
     $fileFactory = $objectManager->get('Magento\\Framework\\View\\File\\Factory');
     $files = array();
     foreach ((array) $layoutUpdatesFile as $filename) {
         $files[] = $fileFactory->create($filename, 'Magento_View');
     }
     $fileSource = $this->_testCase->getMockForAbstractClass('Magento\\Framework\\View\\File\\CollectorInterface');
     $fileSource->expects(\PHPUnit_Framework_TestCase::any())->method('getFiles')->will(\PHPUnit_Framework_TestCase::returnValue($files));
     $cache = $this->_testCase->getMockForAbstractClass('Magento\\Framework\\Cache\\FrontendInterface');
     return $objectManager->create('Magento\\Framework\\View\\Layout\\ProcessorInterface', array('fileSource' => $fileSource, 'cache' => $cache));
 }
开发者ID:aiesh,项目名称:magento2,代码行数:20,代码来源:Layout.php

示例2: create

 /**
  * @param \PHPUnit_Framework_TestCase $test
  * @param \Closure                    $qbCallback
  * @param array                       $fields
  *
  * @return \Doctrine\ORM\EntityManagerInterface
  */
 public static function create(\PHPUnit_Framework_TestCase $test, \Closure $qbCallback, $fields)
 {
     $query = $test->getMockForAbstractClass('Doctrine\\ORM\\AbstractQuery', [], '', false, true, true, ['execute']);
     $query->expects($test->any())->method('execute')->will($test->returnValue(true));
     if (Version::compare('2.5.0') < 1) {
         $entityManager = $test->getMock('Doctrine\\ORM\\EntityManagerInterface');
         $qb = $test->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->setConstructorArgs([$entityManager])->getMock();
     } else {
         $qb = $test->getMockBuilder('Doctrine\\ORM\\QueryBuilder')->disableOriginalConstructor()->getMock();
     }
     $qb->expects($test->any())->method('select')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('getQuery')->will($test->returnValue($query));
     $qb->expects($test->any())->method('where')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('orderBy')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('andWhere')->will($test->returnValue($qb));
     $qb->expects($test->any())->method('leftJoin')->will($test->returnValue($qb));
     $qbCallback($qb);
     $repository = $test->getMockBuilder('Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($test->any())->method('createQueryBuilder')->will($test->returnValue($qb));
     $metadata = $test->getMock('Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata');
     $metadata->expects($test->any())->method('getFieldNames')->will($test->returnValue($fields));
     $metadata->expects($test->any())->method('getName')->will($test->returnValue('className'));
     $em = $test->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $em->expects($test->any())->method('getRepository')->will($test->returnValue($repository));
     $em->expects($test->any())->method('getClassMetadata')->will($test->returnValue($metadata));
     return $em;
 }
开发者ID:zapoyok,项目名称:core-bundle,代码行数:34,代码来源:EntityManagerMockFactory.php

示例3: mockFileOutputStream

function mockFileOutputStream(PHPUnit_Framework_TestCase $testcase, File $file)
{
    $in = $testcase->getMockForAbstractClass('BapCat\\Interfaces\\Persist\\FileOutputStream', [$file]);
    $in->method('write')->will($testcase->returnCallback(function ($data) {
        return strlen($data);
    }));
    return $in;
}
开发者ID:bapcat,项目名称:interfaces,代码行数:8,代码来源:_mocks.php

示例4: mockFileWriter

function mockFileWriter(PHPUnit_Framework_TestCase $testcase, File $file)
{
    $in = $testcase->getMockForAbstractClass(FileWriter::class, [$file]);
    $in->method('write')->will($testcase->returnCallback(function ($data) {
        return strlen($data);
    }));
    return $in;
}
开发者ID:bapcat,项目名称:persist,代码行数:8,代码来源:_mocks.php

示例5: _getMockWithoutConstructorCall

 /**
  * Get mock without call of original constructor
  *
  * @param string $className
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 protected function _getMockWithoutConstructorCall($className)
 {
     $class = new \ReflectionClass($className);
     $mock = null;
     if ($class->isAbstract()) {
         $mock = $this->_testObject->getMockForAbstractClass($className, [], '', false, false);
     } else {
         $mock = $this->_testObject->getMock($className, [], [], '', false, false);
     }
     return $mock;
 }
开发者ID:,项目名称:,代码行数:17,代码来源:

示例6: getMockForAbstractClass

 /**
  * Creates a mock object for an abstract class using a fluent interface.
  *
  * @return PHPUnit_Framework_MockObject_MockObject
  */
 public function getMockForAbstractClass()
 {
     return $this->testCase->getMockForAbstractClass($this->className, $this->constructorArgs, $this->mockClassName, $this->originalConstructor, $this->originalClone, $this->autoload, $this->methods, $this->cloneArguments);
 }
开发者ID:SebFav,项目名称:ApplicationInternet2,代码行数:9,代码来源:MockBuilder.php

示例7: getBindingMock

 /**
  * @param \PHPUnit_Framework_TestCase $test
  *
  * @return \PHPUnit_Framework_MockObject_MockObject|\LightSaml\Binding\AbstractBinding
  */
 public static function getBindingMock(\PHPUnit_Framework_TestCase $test)
 {
     return $test->getMockForAbstractClass(\LightSaml\Binding\AbstractBinding::class);
 }
开发者ID:aarnaud,项目名称:lightSAML,代码行数:9,代码来源:TestHelper.php


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