當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。