本文整理汇总了PHP中PHPUnit_Framework_Test::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Test::getName方法的具体用法?PHP PHPUnit_Framework_Test::getName怎么用?PHP PHPUnit_Framework_Test::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Test
的用法示例。
在下文中一共展示了PHPUnit_Framework_Test::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: endTest
public function endTest(PHPUnit_Framework_Test $test, $time)
{
$startTime = $this->timer[$test->getName()];
$duration = number_format($this->getCurrentTime() - $startTime, 4);
$message = $test->getName() . ' executed in ' . $duration . 's';
$this->log->addInfo($message);
}
示例2: endTest
public function endTest(PHPUnit_Framework_Test $test, $time)
{
//printf("Test '%s' ended.\n", $test->getName());
if ($this->_fails == 0 && $this->_errors == 0) {
echo ' Test passed';
} else {
echo "There were {$this->_fails} failures for " . $test->getName() . "</br>\n";
echo "There were {$this->_errors} errors for " . $test->getName() . "</div>\n";
}
echo '</div>';
}
示例3: addError
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
{
$this->logger->info("Test " . $test->getName() . " threw error");
$errorTestcases = Registry::getInstance()->get(self::ERR_TESTCASES_KEY);
$errorArray = array();
$errorArray[0] = $test;
$errorArray[1] = $e;
array_push($errorTestcases, $errorArray);
Registry::getInstance()->replace(self::ERR_TESTCASES_KEY, $errorTestcases);
$this->logger->info("Adding errored test " . $test->getName() . " to the Registry " . print_r($errorTestcases, true));
$this->logger->info("End " . __METHOD__);
}
示例4: getTestName
/**
* @param \PHPUnit_Framework_Test $test
* @return string
*/
protected function getTestName(\PHPUnit_Framework_Test $test)
{
if ($test instanceof \PHPUnit_Framework_TestCase) {
$name = $test->getName();
} elseif ($test instanceof \PHPUnit_Framework_TestSuite) {
$name = $test->getName();
} elseif ($test instanceof \PHPUnit_Framework_SelfDescribing) {
$name = $test->toString();
} else {
$name = get_class($test);
}
return $name;
}
示例5: addError
/**
* Adds an error to the list of errors.
*
* @param PHPUnit_Framework_Test $test
* @param Exception $e
* @param float $time
*/
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
{
$message = "\n" . $e->getMessage();
if ($e instanceof PHPUnit_Framework_ExpectationFailedException) {
/** @var $e PHPUnit_Framework_ExpectationFailedException */
//$message .= "\n" . $e->getComparisonFailure()->toString();
}
$name = $test->getName(false);
$mail = new Enlight_Components_Mail();
$mail->addTo($this->mailRecipients);
$mail->setSubject('PHPUnit test "' . $name . '" failed.');
$mail->setBodyText($message);
if($test instanceof Enlight_Components_Test_Selenium_TestCase
&& $e instanceof PHPUnit_Framework_ExpectationFailedException
&& $screenshot = $test->getFullScreenshot()) {
$filename = basename($test->getFullScreenshotUrl());
/** @var $test Enlight_Components_Test_Selenium_TestCase */
$mail->createAttachment(
$screenshot,
Zend_Mime::TYPE_OCTETSTREAM,
Zend_Mime::DISPOSITION_ATTACHMENT,
Zend_Mime::ENCODING_BASE64,
$filename
);
}
$mail->send($this->mailTransport);
}
示例6: addFailure
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
printf("Test '%s' failed.\n", $test->getName());
echo "RESPONSE\n\n";
echo "Status Code: " . $test->getResponse()->getHttpResponseCode() . "\n\n";
echo "Headers:\n\n";
foreach ($test->getResponse()->getHeaders() as $header) {
$replace = 'false';
if ($header['replace'] === true) {
$replace = 'true';
}
echo "\t {$header['name']} - {$header['value']} (replace: {$replace})\n";
}
echo "\n";
echo "Body:\n\n" . $test->getResponse()->getBody() . "\n\n";
if ($test->getResponse()->isException()) {
echo "Exceptions:\n\n";
foreach ($test->getResponse()->getException() as $exception) {
echo "\t * Message: {$exception->getMessage()}\n";
echo "\t * File: {$exception->getFile()}\n";
echo "\t * Line: {$exception->getLine()}\n";
echo "\n";
}
}
}
开发者ID:raphaeldealmeida,项目名称:Lagged_Test_PHPUnit_ControllerTestCase_Listener,代码行数:25,代码来源:Listener.php
示例7: endTest
public function endTest(PHPUnit_Framework_Test $test, $time)
{
$current = time();
$took = $current - $this->time;
if ($took > $this->timeLimit) {
echo "\nName: " . $test->getName() . " took " . $took . " second(s) (from: {$this->time}, to: {$current})\n";
}
}
示例8: endTest
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
$time = sprintf('%0.3f sec', microtime(1) - $this->timeTest);
$count = $test->getCount();
$tabs = ceil((29 - strlen($test->getName())) / 8);
echo str_repeat("\t", $tabs) . "{$count} Assertions";
echo $this->colorize("\t{$time}", 'green');
}
示例9: endTest
public function endTest(PHPUnit_Framework_Test $test, $time)
{
$t =& $this->results[$this->currentSuite][$test->getName()];
if (!isset($t['status'])) {
$t['status'] = 'passed';
}
$t['time'] = $time;
$this->currentTest = null;
}
示例10: endTest
/**
* @param \PHPUnit_Framework_Test $test
* @param $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
$this->executionTime = new TimeMeasurement($time);
$this->memoryUsage = memory_get_usage() - $this->memoryUsage;
$this->memoryPeakIncrease = memory_get_peak_usage() - $this->memoryPeakIncrease;
if ($this->haveToSaveTestMeasurement($time)) {
$this->testMeasurementCollection[] = new TestMeasurement($test->getName(), get_class($test), $this->executionTime, new MemoryMeasurement($this->memoryUsage), new MemoryMeasurement($this->memoryPeakIncrease));
}
}
开发者ID:atrapalo,项目名称:phpunit-memory-and-time-usage-listener,代码行数:13,代码来源:TimeAndMemoryTestListener.php
示例11: endTest
public function endTest(PHPUnit_Framework_Test $test, $time)
{
//$fmt = "\nTime: %s ms Name: %s (from: %s, to: %s)";
$fmt = "\nTime: %s ms Name: %s ";
$current = microtime();
$took = $current - $this->time;
if ($took > $this->timeLimit) {
error_log(sprintf($fmt, $took, $test->getName(), $this->time, $current));
}
}
示例12: log
/**
* Persists the given message.
*
* @param string $message
* @param string $level
*/
public function log($message, $level = '')
{
$this->serializer->register('Array', $message->getHeader());
$this->serializer->register('Xml', $message->getBody());
$this->serializer->setDocumentRoot('response');
// due to time issues just a bad hack .. to be refactored asap
$path = TEST_DIR . '/_files/responses';
$file = $path . '/' . $this->generateFilename($this->test->getName());
$filename = $file . '.xml';
if (file_exists($filename)) {
rename($filename, $file . microtime(true) . '.xml');
}
file_put_contents($filename, $this->serializer->serialize());
}
示例13: getDocComment
public function getDocComment(PHPUnit_Framework_Test $test)
{
$class = new ReflectionClass($test);
$method = $class->getMethod($test->getName(false));
$docComment = $method->getDocComment();
$docComment = preg_replace('#[ \\t]*(?:\\/\\*\\*|\\*\\/|\\*)?[ ]{0,1}(.*)?#', '$1', $docComment);
$docComment = "\n" . $docComment;
$endOfDescription = strpos($docComment, "\n@");
if ($endOfDescription !== false) {
$docComment = substr($docComment, 0, $endOfDescription);
}
$docComment = trim($docComment);
return $docComment;
}
示例14: getDocComment
public function getDocComment(PHPUnit_Framework_Test $test)
{
$comment = array();
try {
$class = new ReflectionClass($test);
$method = $class->getMethod($test->getName(false));
$docComment = $method->getDocComment();
$docComment = explode(PHP_EOL, $docComment);
foreach ($docComment as $line) {
$line = trim($line);
$line = trim($line, '*');
$line = trim($line);
if (substr($line, 0, 1) != '@' && strlen($line) > 1) {
$comment[] = $line;
}
}
} catch (Exception $e) {
}
return join(PHP_EOL, $comment);
}
示例15: startTest
public function startTest(\PHPUnit_Framework_Test $test)
{
if ($test instanceof \PHPUnit_Framework_Warning) {
return;
}
if (!$test instanceof AbstractTestCase) {
throw new \InvalidArgumentException('Test case must be descendant of Lmc\\Steward\\Test\\AbstractTestCase');
}
$config = ConfigProvider::getInstance();
// Initialize NullWebDriver if self::NO_BROWSER_ANNOTATION is used on testcase class or test method
$testCaseAnnotations = AnnotationsParser::getAll(new \ReflectionClass($test));
$testAnnotations = AnnotationsParser::getAll(new \ReflectionMethod($test, $test->getName(false)));
if (isset($testCaseAnnotations[self::NO_BROWSER_ANNOTATION]) || isset($testAnnotations[self::NO_BROWSER_ANNOTATION])) {
$test->wd = new NullWebDriver();
$test->log('Initializing Null WebDriver for "%s::%s" (@%s annotation used %s)', get_class($test), $test->getName(), self::NO_BROWSER_ANNOTATION, isset($testCaseAnnotations[self::NO_BROWSER_ANNOTATION]) ? 'on class' : 'on method');
return;
}
// Initialize real WebDriver otherwise
$test->log('Initializing "%s" WebDriver for "%s::%s"', $config->browserName, get_class($test), $test->getName());
$capabilities = new \DesiredCapabilities([\WebDriverCapabilityType::BROWSER_NAME => $config->browserName, \WebDriverCapabilityType::PLATFORM => \WebDriverPlatform::ANY]);
$this->createWebDriver($test, $config->serverUrl . '/wd/hub', $this->setupCustomCapabilities($capabilities, $config->browserName), $connectTimeoutMs = 2 * 60 * 1000, $requestTimeoutMs = 60 * 60 * 1000);
}