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


PHP PHPUnit_Framework_TestCase::getName方法代码示例

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


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

 /**
  * Determine the "full" test name (including the suite name if it is set)
  *
  * @param \PHPUnit_Framework_TestCase $test
  * @return string
  */
 private function getCurrentTestName(\PHPUnit_Framework_TestCase $test)
 {
     if (null === $this->currentSuite) {
         return $test->getName(true);
     }
     return $this->currentSuite->getName() . '::' . $test->getName(true);
 }
开发者ID:AydinHassan,项目名称:BetterReflection,代码行数:13,代码来源:TestListener.php

示例3: objectMatch

 /**
  * Check whether test case is matched to specified object
  *
  * @param string $value
  * @return bool|null
  */
 protected function objectMatch($value)
 {
     if (!$this->testCase instanceof Injectable) {
         return null;
     }
     $arguments = $this->objectManager->prepareArguments($this->testCase, $this->testCase->getName(false));
     foreach ($arguments as $argument) {
         if ($argument instanceof $value) {
             return true;
         }
     }
     return false;
 }
开发者ID:Mohitsahu123,项目名称:mtf,代码行数:19,代码来源:ObjectComposite.php

示例4: 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

示例5: runTest

 public static function runTest(\PHPUnit_Framework_TestCase $test)
 {
     if ($test->getName(false) === NULL) {
         throw new \PHPUnit_Framework_Exception('PHPUnit_Framework_TestCase::$name must not be NULL.');
     }
     try {
         $class = new \ReflectionClass($test);
         $method = $class->getMethod($test->getName(false));
         $methodName = $method->getName();
         $instance = new static();
         $instance->setTest($test);
         $instance->setClass($class);
         $instance->setMethod($method);
         $instance->cleanUpClass();
         $phpSpock = $instance->createPhpSpockInstance();
         $assertionCount = $phpSpock->runWithAdapter($instance, array($test, $methodName));
         $test->addToAssertionCount($assertionCount);
     } catch (\ReflectionException $e) {
         $test->fail($e->getMessage());
     } catch (\Exception $e) {
         $expectedExceptionClass = $test->getExpectedException();
         if (!$e instanceof \PHPUnit_Framework_IncompleteTest && !$e instanceof \PHPUnit_Framework_SkippedTest && is_string($test->getExpectedException()) && $e instanceof $expectedExceptionClass) {
             if (isset($methodName)) {
                 $expectedException = self::getExpectedExceptionFromAnnotation($test, $methodName);
                 if (is_string($expectedException['message']) && !empty($expectedException['message'])) {
                     $test->assertContains($expectedException['message'], $e->getMessage());
                 }
                 if (is_int($expectedException['code']) && $expectedException['code'] !== 0) {
                     $test->assertEquals($expectedException['code'], $e->getCode());
                 }
                 $test->addToAssertionCount(1);
                 return;
             }
         } else {
             throw $e;
         }
     }
 }
开发者ID:aleczhang,项目名称:phpspock,代码行数:38,代码来源:PhpUnitAdapter.php

示例6: setUpContext

 /**
  * @param \PHPUnit_Framework_TestCase $testCase
  */
 private function setUpContext(\PHPUnit_Framework_TestCase $testCase)
 {
     $testMethodArguments = array();
     $reflectionMethod = new \ReflectionMethod($testCase, $testCase->getName(false));
     $annotationReader = AnnotationReaderFactory::getAnnotationReader();
     $annotations = $annotationReader->getMethodAnnotations($reflectionMethod);
     foreach ($annotations as $i => $annotation) {
         if ($annotation instanceof Arrange) {
             $arrangeOutput = $this->runAnnotations($testCase, $annotation, $i);
             if ($arrangeOutput !== null) {
                 $testMethodArguments[] = $arrangeOutput;
             }
         }
     }
     $testCase->setDependencyInput($testMethodArguments);
 }
开发者ID:nikoms,项目名称:phpunit-arrange,代码行数:19,代码来源:ArrangeListener.php

示例7: getArrangeLines

 /**
  * @param \PHPUnit_Framework_TestCase $test
  * @return array
  */
 private function getArrangeLines(\PHPUnit_Framework_TestCase $test)
 {
     $arranges = [];
     $annotationReader = AnnotationReaderFactory::getAnnotationReader();
     foreach (ArrangeListener::$inputs[$test->getName(true)] as $i => $arrangeMethods) {
         foreach ($arrangeMethods as $arrangeMethod => $arguments) {
             try {
                 $describe = $this->getArrangeDescription($test, $annotationReader, $arrangeMethod);
                 $arranges[] = $this->getArrangeLine($describe, $arguments);
             } catch (\DomainException $ex) {
                 continue;
             }
         }
     }
     return $arranges;
 }
开发者ID:nikoms,项目名称:phpunit-arrange,代码行数:20,代码来源:ArrangeResultPrinter.php

示例8: paintSkip

 /**
  * Prints the message for skipping tests.
  *
  * @param string $message Text of skip condition.
  * @param PHPUnit_Framework_TestCase $test the test method skipped
  * @return void
  */
 public function paintSkip($message, $test)
 {
     echo "<li class='skipped'>\n";
     echo "<span>Skipped</span> ";
     echo $test->getName() . ': ' . $this->_htmlEntities($message->getMessage());
     echo "</li>\n";
 }
开发者ID:coder-d,项目名称:payment_library,代码行数:14,代码来源:CakeHtmlReporter.php

示例9: createTestId

 /**
  * Creates a unique string ID for $test that can be used in URLs.
  *
  * @param PHPUnit_Framework_TestCase $test a test for which to create an ID
  *
  * @return string a unique ID for $test, not htmlspecialchared or URL-encoded yet
  */
 protected function createTestId(PHPUnit_Framework_TestCase $test)
 {
     $testNameParts = explode(' ', $test->getName());
     // This is quite a hack.
     // @see http://forge.typo3.org/issues/11735
     if (strpos($this->currentTestCaseName, '::') !== false) {
         $result = $testNameParts[0] . '(' . $this->getTestCaseName() . ')';
     } else {
         $result = $this->getTestCaseName() . '::' . $testNameParts[0];
     }
     return $result;
 }
开发者ID:TrueType,项目名称:phpunit,代码行数:19,代码来源:TestListener.php

示例10: addGeneratedTestTo

 private static function addGeneratedTestTo(PHPUnit_Framework_TestSuite $suite, PHPUnit_Framework_TestCase $test, $classGroups)
 {
     list($methodName, ) = explode(' ', $test->getName());
     $test->setDependencies(PHPUnit_Util_Test::getDependencies(get_class($test), $methodName));
     $suite->addTest($test, $classGroups);
 }
开发者ID:DaveNascimento,项目名称:civicrm-packages,代码行数:6,代码来源:SeleniumTestSuite.php

示例11: getTime

 private function getTime(TestCase $test)
 {
     $name = $test->getName();
     $class = get_class($test);
     foreach ($this->timings as $timing) {
         if ($timing['class'] === $class && $timing['test'] === $name) {
             return $timing['time'];
         }
     }
 }
开发者ID:petertilsen,项目名称:phpunit-clever-and-smart,代码行数:10,代码来源:PrioritySorter.php

示例12: getName

 public function getName($withDataSet = TRUE)
 {
     return $this->suite->getName() . ' - ' . parent::getName($withDataSet);
 }
开发者ID:serrg1994,项目名称:opensocial-php-client,代码行数:4,代码来源:OnlineTestCase.php

示例13: hasTestCaseDataSet

 /**
  * @param \PHPUnit_Framework_TestCase $testCase
  * @return bool
  */
 private function hasTestCaseDataSet(\PHPUnit_Framework_TestCase $testCase)
 {
     return $testCase->getName(false) === $testCase->getName(true);
 }
开发者ID:nikoms,项目名称:phpunit-fail-lover,代码行数:8,代码来源:TestCaseFactory.php

示例14: getRunlevel

 /**
  * Determines which location shall be fetched from the list of configured locations.
  *
  * @param \PHPUnit_Framework_TestCase $test
  *
  * @return string
  */
 protected function getRunlevel(\PHPUnit_Framework_TestCase $test)
 {
     return $this->extractRunlevelFromTestName($test->getName());
 }
开发者ID:lapistano,项目名称:wsunit,代码行数:11,代码来源:WebServiceListener.php


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