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


PHP PHPUnit_Framework_TestCase::returnSelf方法代码示例

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


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

示例1: create

 /**
  * Create a new mock of the curlbuilder and return
  * the given filename as content
  *
  * @access public
  * @param  PHPUnit_Framework_TestCase   $instance
  * @return mock
  */
 public static function create($instance)
 {
     $reflection = new \ReflectionMethod($instance, $instance->getName());
     $doc_block = $reflection->getDocComment();
     $responsefile = self::parseDocBlock($doc_block, '@responsefile');
     $responsecode = self::parseDocBlock($doc_block, '@responsecode');
     $defaultheaders = array("X-Ratelimit-Limit" => "1000", "X-Ratelimit-Remaining" => "998", "X-Varnish" => "4059929980");
     $skipmock = self::parseDocBlock($doc_block, '@skipmock');
     if (empty($responsecode)) {
         $responsecode = [201];
     }
     if (empty($responsefile)) {
         $responsefile = [$instance->getName()];
     }
     // Setup Curlbuilder mock
     $curlbuilder = $instance->getMockBuilder("\\DirkGroenen\\Pinterest\\Utils\\CurlBuilder")->getMock();
     $curlbuilder->expects($instance->any())->method('create')->will($instance->returnSelf());
     // Build response file path
     $responseFilePath = __DIR__ . '/../responses/' . (new \ReflectionClass($instance))->getShortName() . '/' . $responsefile[0] . ".json";
     if (file_exists($responseFilePath)) {
         $curlbuilder->expects($instance->once())->method('execute')->will($instance->returnValue(file_get_contents($responseFilePath)));
     }
     $curlbuilder->expects($instance->any())->method('getInfo')->will($instance->returnValue($responsecode[0]));
     return $curlbuilder;
 }
开发者ID:veksa,项目名称:Pinterest-API-PHP,代码行数:33,代码来源:CurlBuilderMock.php

示例2: getBuilder

 /**
  * Get data object builder
  *
  * @param string $className
  * @param array $arguments
  * @return object
  */
 protected function getBuilder($className, array $arguments)
 {
     $objectFactory = $this->_testObject->getMock('Magento\\Framework\\Api\\ObjectFactory', [], [], '', false);
     if (!isset($arguments['objectFactory'])) {
         $arguments['objectFactory'] = $objectFactory;
     }
     $constructArguments = $this->getConstructArguments($className, $arguments);
     $reflectionClass = new \ReflectionClass($className);
     $builderObject = $reflectionClass->newInstanceArgs($constructArguments);
     $objectFactory->expects($this->_testObject->any())->method('populateWithArray')->will($this->_testObject->returnSelf());
     $objectFactory->expects($this->_testObject->any())->method('populate')->will($this->_testObject->returnSelf());
     $objectFactory->expects($this->_testObject->any())->method('create')->will($this->_testObject->returnCallback(function ($className, $arguments) {
         $reflectionClass = new \ReflectionClass($className);
         $constructorMethod = $reflectionClass->getConstructor();
         $parameters = $constructorMethod->getParameters();
         $args = [];
         foreach ($parameters as $parameter) {
             $parameterName = $parameter->getName();
             if (isset($arguments[$parameterName])) {
                 $args[] = $arguments[$parameterName];
             } else {
                 if ($parameter->isArray()) {
                     $args[] = [];
                 } elseif ($parameter->allowsNull()) {
                     $args[] = null;
                 } else {
                     $mock = $this->_getMockWithoutConstructorCall($parameter->getClass()->getName());
                     $args[] = $mock;
                 }
             }
         }
         return $reflectionClass->newInstanceArgs($args);
     }));
     return $builderObject;
 }
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:42,代码来源:ObjectManager.php

示例3: getPlainMock

 /**
  * Get a plain command-object mock
  *
  * @param  string $sReturn
  *
  * @return \Testy\Util\Command
  */
 public static function getPlainMock($sReturn = '')
 {
     $oMockBuilder = new \PHPUnit_Framework_MockObject_Generator();
     $oCommandMock = $oMockBuilder->getMock('\\Testy\\Util\\Command');
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('execute')->will(\PHPUnit_Framework_TestCase::returnSelf());
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('reset')->will(\PHPUnit_Framework_TestCase::returnSelf());
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('setCommand')->will(\PHPUnit_Framework_TestCase::returnSelf());
     $oCommandMock->expects(\PHPUnit_Framework_TestCase::any())->method('get')->will(\PHPUnit_Framework_TestCase::returnValue($sReturn));
     return $oCommandMock;
 }
开发者ID:hpbuniat,项目名称:testy,代码行数:17,代码来源:Command.php

示例4: getBuilder

 /**
  * Get data object builder
  *
  * @param string $className
  * @param array $arguments
  * @return object
  */
 protected function getBuilder($className, array $arguments)
 {
     $objectFactory = $this->_testObject->getMock('Magento\\Framework\\Api\\ObjectFactory', [], [], '', false);
     if (!isset($arguments['objectFactory'])) {
         $arguments['objectFactory'] = $objectFactory;
     }
     $constructArguments = $this->getConstructArguments($className, $arguments);
     $reflectionClass = new \ReflectionClass($className);
     $builderObject = $reflectionClass->newInstanceArgs($constructArguments);
     $objectFactory->expects($this->_testObject->any())->method('populateWithArray')->will($this->_testObject->returnSelf());
     $objectFactory->expects($this->_testObject->any())->method('populate')->will($this->_testObject->returnSelf());
     $objectFactory->expects($this->_testObject->any())->method('create')->will($this->_testObject->returnCallback(function ($className, $arguments) {
         $reflectionClass = new \ReflectionClass($className);
         return $reflectionClass->newInstanceArgs($arguments);
     }));
     return $builderObject;
 }
开发者ID:,项目名称:,代码行数:24,代码来源:

示例5: create

 /**
  * Create a new mock of the curlbuilder and return 
  * the given filename as content
  * 
  * @access public
  * @param  PHPUnit_Framework_TestCase   $instance
  * @return mock
  */
 public static function create($instance)
 {
     $reflection = new \ReflectionMethod($instance, $instance->getName());
     $doc_block = $reflection->getDocComment();
     $responsefile = self::parseDocBlock($doc_block, '@responsefile');
     $responsecode = self::parseDocBlock($doc_block, '@responsecode');
     if (empty($responsecode)) {
         $responsecode = [201];
     }
     if (empty($responsefile)) {
         $responsefile = [$instance->getName()];
     }
     // Setup Curlbuilder mock
     $curlbuilder = $instance->getMockBuilder("\\DirkGroenen\\Pinterest\\Utils\\CurlBuilder")->getMock();
     $curlbuilder->expects($instance->once())->method('create')->will($instance->returnSelf());
     $curlbuilder->expects($instance->once())->method('execute')->will($instance->returnValue(file_get_contents(__DIR__ . '/../responses/' . (new \ReflectionClass($instance))->getShortName() . '/' . $responsefile[0] . ".json")));
     $curlbuilder->expects($instance->any())->method('getInfo')->will($instance->returnValue($responsecode[0]));
     return $curlbuilder;
 }
开发者ID:sfai05,项目名称:Pinterest-API-PHP,代码行数:27,代码来源:CurlBuilderMock.php

示例6: returnSelf

/**
 * Returns the current object.
 *
 * This method is useful when mocking a fluent interface.
 *
 * @return PHPUnit_Framework_MockObject_Stub_ReturnSelf
 * @since  Method available since Release 3.6.0
 */
function returnSelf()
{
    return PHPUnit_Framework_TestCase::returnSelf();
}
开发者ID:nbalonso,项目名称:MunkiFace,代码行数:12,代码来源:Functions.php


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