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


PHP PHPUnit_Util_Test::getExpectedException方法代码示例

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


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

示例1: testGetExpectedException

 public function testGetExpectedException()
 {
     $this->assertEquals(array('class' => 'FooBarBaz', 'code' => 0, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testOne'));
     $this->assertEquals(array('class' => 'Foo_Bar_Baz', 'code' => 0, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testTwo'));
     $this->assertEquals(array('class' => 'Foo\\Bar\\Baz', 'code' => 0, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testThree'));
     $this->assertEquals(array('class' => 'ほげ', 'code' => 0, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFour'));
     $this->assertEquals(array('class' => 'Class', 'code' => 1234, 'message' => 'Message'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFive'));
     $this->assertEquals(array('class' => 'Class', 'code' => 1234, 'message' => 'Message'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSix'));
 }
开发者ID:proofek,项目名称:phpunit,代码行数:9,代码来源:TestTest.php

示例2: testGetExpectedException

 public function testGetExpectedException()
 {
     $this->assertSame(array('class' => 'FooBarBaz', 'code' => NULL, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testOne'));
     $this->assertSame(array('class' => 'Foo_Bar_Baz', 'code' => NULL, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testTwo'));
     $this->assertSame(array('class' => 'Foo\\Bar\\Baz', 'code' => NULL, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testThree'));
     $this->assertSame(array('class' => 'ほげ', 'code' => NULL, 'message' => ''), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFour'));
     $this->assertSame(array('class' => 'Class', 'code' => 1234, 'message' => 'Message'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testFive'));
     $this->assertSame(array('class' => 'Class', 'code' => 1234, 'message' => 'Message'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSix'));
     $this->assertSame(array('class' => 'Class', 'code' => 'ExceptionCode', 'message' => 'Message'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testSeven'));
     $this->assertSame(array('class' => 'Class', 'code' => 0, 'message' => 'Message'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testEight'));
     $this->assertSame(array('class' => 'Class', 'code' => ExceptionTest::ERROR_CODE, 'message' => ExceptionTest::ERROR_MESSAGE), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testNine'));
     $this->assertSame(array('class' => 'Class', 'code' => My\Space\ExceptionNamespaceTest::ERROR_CODE, 'message' => My\Space\ExceptionNamespaceTest::ERROR_MESSAGE), PHPUnit_Util_Test::getExpectedException('My\\Space\\ExceptionNamespaceTest', 'testConstants'));
     // Ensure the Class::CONST expression is only evaluated when the constant really exists
     $this->assertSame(array('class' => 'Class', 'code' => 'ExceptionTest::UNKNOWN_CODE_CONSTANT', 'message' => 'ExceptionTest::UNKNOWN_MESSAGE_CONSTANT'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testUnknownConstants'));
     $this->assertSame(array('class' => 'Class', 'code' => 'My\\Space\\ExceptionNamespaceTest::UNKNOWN_CODE_CONSTANT', 'message' => 'My\\Space\\ExceptionNamespaceTest::UNKNOWN_MESSAGE_CONSTANT'), PHPUnit_Util_Test::getExpectedException('My\\Space\\ExceptionNamespaceTest', 'testUnknownConstants'));
 }
开发者ID:ramonornela,项目名称:phpunit,代码行数:16,代码来源:TestTest.php

示例3: setExpectedExceptionFromAnnotation

 /**
  * @since  Method available since Release 3.4.0
  */
 protected function setExpectedExceptionFromAnnotation()
 {
     try {
         $expectedException = PHPUnit_Util_Test::getExpectedException(get_class($this), $this->name);
         if ($expectedException !== false) {
             $this->setExpectedException($expectedException['class'], $expectedException['message'], $expectedException['code']);
             if (!empty($expectedException['message_regex'])) {
                 $this->setExpectedExceptionRegExp($expectedException['class'], $expectedException['message_regex'], $expectedException['code']);
             }
         }
     } catch (ReflectionException $e) {
     }
 }
开发者ID:emsdog,项目名称:lumen-todo,代码行数:16,代码来源:TestCase.php

示例4: setExpectedExceptionFromAnnotation

 /**
  * @since  Method available since Release 3.4.0
  */
 protected function setExpectedExceptionFromAnnotation()
 {
     try {
         $method = new ReflectionMethod(get_class($this), $this->name);
         $methodDocComment = $method->getDocComment();
         $expectedException = PHPUnit_Util_Test::getExpectedException($methodDocComment);
         if ($expectedException !== FALSE) {
             $this->setExpectedException($expectedException['class'], $expectedException['message'], $expectedException['code']);
         }
     } catch (ReflectionException $e) {
     }
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:15,代码来源:TestCase.php

示例5: testGetExpectedException

 public function testGetExpectedException()
 {
     $this->assertEquals(array('class' => 'FooBarBaz', 'code' => 0, 'message' => ''), PHPUnit_Util_Test::getExpectedException('@expectedException FooBarBaz'));
     $this->assertEquals(array('class' => 'Foo_Bar_Baz', 'code' => 0, 'message' => ''), PHPUnit_Util_Test::getExpectedException('@expectedException Foo_Bar_Baz'));
     $this->assertEquals(array('class' => 'Foo\\Bar\\Baz', 'code' => 0, 'message' => ''), PHPUnit_Util_Test::getExpectedException('@expectedException Foo\\Bar\\Baz'));
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:6,代码来源:TestTest.php

示例6: testGetExpectedRegExp

 /**
  * @covers PHPUnit_Util_Test::getExpectedException
  */
 public function testGetExpectedRegExp()
 {
     $this->assertArraySubset(array('message_regex' => '#regex#'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testWithRegexMessage'));
     $this->assertArraySubset(array('message_regex' => '#regex#'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testWithRegexMessageFromClassConstant'));
     $this->assertArraySubset(array('message_regex' => 'ExceptionTest::UNKNOWN_MESSAGE_REGEX_CONSTANT'), PHPUnit_Util_Test::getExpectedException('ExceptionTest', 'testWithUnknowRegexMessageFromClassConstant'));
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:9,代码来源:TestTest.php

示例7: createTest

 /**
  * @param  ReflectionClass $theClass
  * @param  string          $name
  * @param  array           $classGroups
  * @return PHPUnit_Framework_Test
  */
 public static function createTest(ReflectionClass $theClass, $name, array $classGroups = array())
 {
     $className = $theClass->getName();
     $method = new ReflectionMethod($className, $name);
     $methodDocComment = $method->getDocComment();
     if (!$theClass->isInstantiable()) {
         return self::warning(sprintf('Cannot instantiate class "%s".', $className));
     }
     $constructor = $theClass->getConstructor();
     $expectedException = PHPUnit_Util_Test::getExpectedException($methodDocComment);
     if ($constructor !== NULL) {
         $parameters = $constructor->getParameters();
         // TestCase() or TestCase($name)
         if (count($parameters) < 2) {
             $test = new $className();
         } else {
             $data = PHPUnit_Util_Test::getProvidedData($className, $name, $methodDocComment);
             $groups = PHPUnit_Util_Test::getGroups($methodDocComment, $classGroups);
             if (is_array($data) || $data instanceof Iterator) {
                 $test = new PHPUnit_Framework_TestSuite($className . '::' . $name);
                 foreach ($data as $_dataName => $_data) {
                     $_test = new $className($name, $_data, $_dataName);
                     if ($_test instanceof PHPUnit_Framework_TestCase && isset($expectedException)) {
                         $_test->setExpectedException($expectedException['class'], $expectedException['message'], $expectedException['code']);
                     }
                     $test->addTest($_test, $groups);
                 }
             } else {
                 $test = new $className();
             }
         }
     }
     if ($test instanceof PHPUnit_Framework_TestCase) {
         $test->setName($name);
         if (isset($expectedException)) {
             $test->setExpectedException($expectedException['class'], $expectedException['message'], $expectedException['code']);
         }
     }
     return $test;
 }
开发者ID:cjmi,项目名称:miniblog,代码行数:46,代码来源:TestSuite.php

示例8: getExpectedExceptionFromAnnotation

 /**
  * @since  Method available since Release 3.4.0
  * @param $class
  * @param $methodName
  * @return \Exception | null
  */
 protected static function getExpectedExceptionFromAnnotation($class, $methodName)
 {
     try {
         return \PHPUnit_Util_Test::getExpectedException(get_class($class), $methodName);
     } catch (\ReflectionException $e) {
     }
     return null;
 }
开发者ID:aleczhang,项目名称:phpspock,代码行数:14,代码来源:PhpUnitAdapter.php

示例9: setExpectedExceptionFromAnnotation

 /**
  * @since Method available since Release 3.4.0
  */
 protected function setExpectedExceptionFromAnnotation()
 {
     try {
         $expectedException = PHPUnit_Util_Test::getExpectedException(get_class($this), $this->name);
         if ($expectedException !== false) {
             $this->expectException($expectedException['class']);
             if ($expectedException['code'] !== null) {
                 $this->expectExceptionCode($expectedException['code']);
             }
             if ($expectedException['message'] !== '') {
                 $this->expectExceptionMessage($expectedException['message']);
             } elseif ($expectedException['message_regex'] !== '') {
                 $this->expectExceptionMessageRegExp($expectedException['message_regex']);
             }
         }
     } catch (ReflectionException $e) {
     }
 }
开发者ID:phecho,项目名称:phpunit,代码行数:21,代码来源:TestCase.php


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