本文整理汇总了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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}