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


PHP MockInterface::mockery_getExpectationsFor方法代码示例

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


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

示例1: _buildDemeterChain

 /**
  * Sets up expectations on the members of the CompositeExpectation and
  * builds up any demeter chain that was passed to shouldReceive
  *
  * @param \Mockery\MockInterface $mock
  * @param string $arg
  * @param callable $add
  * @throws Mockery\Exception
  * @return \Mockery\ExpectationDirector
  */
 protected static function _buildDemeterChain(\Mockery\MockInterface $mock, $arg, $add)
 {
     /** @var Mockery\Container $container */
     $container = $mock->mockery_getContainer();
     $methodNames = explode('->', $arg);
     reset($methodNames);
     if (!\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() && !$mock->mockery_isAnonymous() && !in_array(current($methodNames), $mock->mockery_getMockableMethods())) {
         throw new \Mockery\Exception('Mockery\'s configuration currently forbids mocking the method ' . current($methodNames) . ' as it does not exist on the class or object ' . 'being mocked');
     }
     /** @var ExpectationInterface|null $exp */
     $exp = null;
     /** @var Callable $nextExp */
     $nextExp = function ($method) use($add) {
         return $add($method);
     };
     while (true) {
         $method = array_shift($methodNames);
         $exp = $mock->mockery_getExpectationsFor($method);
         if (is_null($exp) || self::noMoreElementsInChain($methodNames)) {
             $exp = $nextExp($method);
             if (self::noMoreElementsInChain($methodNames)) {
                 break;
             }
             $mock = self::getNewDemeterMock($container, $method, $exp);
         } else {
             $demeterMockKey = $container->getKeyOfDemeterMockFor($method);
             if ($demeterMockKey) {
                 $mock = self::getExistingDemeterMock($container, $demeterMockKey);
             }
         }
         $nextExp = function ($n) use($mock) {
             return $mock->shouldReceive($n);
         };
     }
     return $exp;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:46,代码来源:Mockery.php

示例2: _buildDemeterChain

 /**
  * Sets up expectations on the members of the CompositeExpectation and
  * builds up any demeter chain that was passed to shouldReceive
  *
  * @param \Mockery\MockInterface $mock
  * @param string $arg
  * @param Closure $add
  * @return \Mockery\ExpectationDirector
  */
 protected static function _buildDemeterChain(\Mockery\MockInterface $mock, $arg, $add)
 {
     $container = $mock->mockery_getContainer();
     $names = explode('->', $arg);
     reset($names);
     if (!\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() && !in_array(current($names), $mock->mockery_getMockableMethods())) {
         throw new \Mockery\Exception('Mockery\'s configuration currently forbids mocking the method ' . current($names) . ' as it does not exist on the class or object ' . 'being mocked');
     }
     $exp = null;
     $nextExp = function ($n) use($add) {
         return $add($n);
     };
     while (true) {
         $method = array_shift($names);
         $exp = $mock->mockery_getExpectationsFor($method);
         $needNew = false;
         if (is_null($exp) || empty($names)) {
             $needNew = true;
         }
         if ($needNew) {
             $exp = $nextExp($method);
         }
         if (empty($names)) {
             break;
         }
         if ($needNew) {
             $mock = $container->mock('demeter_' . $method);
             $exp->andReturn($mock);
         }
         $nextExp = function ($n) use($mock) {
             return $mock->shouldReceive($n);
         };
     }
     return $exp;
 }
开发者ID:rojoca,项目名称:mockery,代码行数:44,代码来源:Mockery.php


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