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


PHP PHPUnit_Framework_TestCase::throwException方法代码示例

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


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

示例1: getValidIpAddress

 /**
  * @test
  */
 public function getValidIpAddress()
 {
     $ip = '127.0.0.1';
     $exception = parent::throwException(new CouldNotResolveIpAddressException());
     $ipProvider = $this->getIpProviderMock($exception, 'foobar', $ip);
     $currentIpAddress = $ipProvider->getCurrentIpAddress();
     parent::assertEquals($ip, $currentIpAddress);
 }
开发者ID:oqq,项目名称:ip-provider,代码行数:11,代码来源:IpProviderTest.php

示例2: createUndeclaredMethods

 private function createUndeclaredMethods()
 {
     foreach (array_keys($this->originClassMethods) as $originalMethodName) {
         if (false == array_key_exists($originalMethodName, $this->mockMethods)) {
             $method = $this->mock->expects($this->testCase->any());
             $method->method($originalMethodName);
             $method->will($this->testCase->throwException(new UndeclaredMethodInvocationException($originalMethodName)));
         }
     }
 }
开发者ID:jelito,项目名称:devstack,代码行数:10,代码来源:Builder.php

示例3: parseMockMethodArgs

 /** @return array */
 protected function parseMockMethodArgs($method, array $args)
 {
     $expects = TestCase::any();
     $with = null;
     $will = TestCase::returnValue(null);
     if (count($args) == 1) {
         if ($args[0] instanceof InvokedRecorder || $args[0] instanceof InvokedAtIndex) {
             $expects = $args[0];
         } else {
             $will = $args[0];
         }
     } elseif (count($args) == 2) {
         if ($args[1] instanceof InvokedRecorder || $args[1] instanceof InvokedAtIndex) {
             if (is_array($args[0])) {
                 list($with, $expects) = $args;
             } else {
                 list($will, $expects) = $args;
             }
         } elseif (is_array($args[0])) {
             list($with, $will) = $args;
         } else {
             throw new \InvalidArgumentException();
         }
     } elseif (count($args) == 3) {
         if (is_array($args[0]) && ($args[2] instanceof InvokedRecorder || $args[2] instanceof InvokedAtIndex)) {
             list($with, $will, $expects) = $args;
         } else {
             throw new \InvalidArgumentException();
         }
     }
     if ($will instanceof \Exception) {
         $will = PhpUnitTestCase::throwException($will);
     } elseif (!$will instanceof Stub && !$will instanceof \Closure && !is_null($will)) {
         $will = PhpUnitTestCase::returnValue($will);
     }
     return array('method' => $method, 'expects' => $expects, 'with' => $with, 'will' => $will);
 }
开发者ID:ptrofimov,项目名称:xpmock,代码行数:38,代码来源:Base.php

示例4: throwException

/**
 *
 *
 * @param  Exception $exception
 * @return PHPUnit_Framework_MockObject_Stub_Exception
 * @since  Method available since Release 3.1.0
 */
function throwException(Exception $exception)
{
    return PHPUnit_Framework_TestCase::throwException($exception);
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:11,代码来源:Functions.php


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