本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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);
}
示例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;
}
示例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";
}
示例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;
}
示例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);
}
示例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'];
}
}
}
示例12: getName
public function getName($withDataSet = TRUE)
{
return $this->suite->getName() . ' - ' . parent::getName($withDataSet);
}
示例13: hasTestCaseDataSet
/**
* @param \PHPUnit_Framework_TestCase $testCase
* @return bool
*/
private function hasTestCaseDataSet(\PHPUnit_Framework_TestCase $testCase)
{
return $testCase->getName(false) === $testCase->getName(true);
}
示例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());
}