本文整理汇总了PHP中PHPUnit_Framework_Test::getTestResultObject方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Test::getTestResultObject方法的具体用法?PHP PHPUnit_Framework_Test::getTestResultObject怎么用?PHP PHPUnit_Framework_Test::getTestResultObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Test
的用法示例。
在下文中一共展示了PHPUnit_Framework_Test::getTestResultObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: endTest
/**
* endTest is called after each test and checks if \Mockery::close() has
* been called, and will let the test fail if it hasn't.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
if (!$test instanceof \PHPUnit_Framework_TestCase) {
// We need the getTestResultObject and getStatus methods which are
// not part of the interface.
return;
}
if ($test->getStatus() !== \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
// If the test didn't pass there is no guarantee that
// verifyMockObjects and assertPostConditions have been called.
// And even if it did, the point here is to prevent false
// negatives, not to make failing tests fail for more reasons.
return;
}
try {
// The self() call is used as a sentinel. Anything that throws if
// the container is closed already will do.
\Mockery::self();
} catch (\LogicException $_) {
return;
}
$e = new \PHPUnit_Framework_ExpectationFailedException(sprintf("Mockery's expectations have not been verified. Make sure that \\Mockery::close() is called at the end of the test. Consider using %s\\MockeryPHPUnitIntegration or extending %s\\MockeryTestCase.", __NAMESPACE__, __NAMESPACE__));
$result = $test->getTestResultObject();
$result->addFailure($test, $e, $time);
}
示例2: endTest
/**
* After each test, perform Mockery verification tasks and cleanup the
* statically stored Mockery container for the next test.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
try {
\Mockery::close();
} catch (\Exception $e) {
$result = $test->getTestResultObject();
$result->addError($test, $e, $time);
}
}
示例3: endTest
/**
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
try {
if ($test instanceof \PHPUnit_Framework_TestCase) {
$test->addToAssertionCount(MatcherAssert::getCount());
}
} catch (\Exception $e) {
$result = $test->getTestResultObject();
$result->addError($test, $e, $time);
}
}
示例4: endTest
/**
* After each test, perform ehough_mockery_Mockery verification tasks and cleanup the
* statically stored ehough_mockery_Mockery container for the next test.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(PHPUnit_Framework_Test $test, $time)
{
try {
$container = ehough_mockery_Mockery::getContainer();
if ($container != null) {
$expectation_count = $container->mockery_getExpectationCount();
$test->addToAssertionCount($expectation_count);
}
ehough_mockery_Mockery::close();
} catch (Exception $e) {
$result = $test->getTestResultObject();
$result->addError($test, $e, $time);
}
}
示例5: addFailure
/**
* A failure occurred.
*
* @todo Add check that $test is instance of PHPUnit_Framework_TestCase
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$failures = array();
$testResult = $test->getTestResultObject();
/** @var $failure PHPUnit_Framework_TestFailure */
foreach ($testResult->failures() as $failure) {
$hash = "{$e->getMessage()} {$e->getTraceAsString()}";
if (isset($failures[$hash])) {
continue;
}
$array = array('type' => self::MESSAGE_COMPARISON_FAILURE, 'name' => $test->getName(), 'message' => $e->getMessage(), 'details' => $e->getTraceAsString());
/** @var $exception PHPUnit_Framework_ExpectationFailedException */
$exception = $failure->thrownException();
$comparisonFailure = $exception->getComparisonFailure();
if ($comparisonFailure instanceof PHPUnit_Framework_ComparisonFailure) {
$array += array('expected' => $comparisonFailure->getExpectedAsString(), 'actual' => $comparisonFailure->getActualAsString());
}
$message = $this->getServiceMessage(self::MESSAGE_TEST_FAILED, $array);
$this->write($message);
$failures[$hash] = true;
}
}
示例6: endTest
/**
* A test ended.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
* @return void
*/
public function endTest(PHPUnit_Framework_Test $test, $time)
{
$t =& $this->test($test->getName());
if (!$t['status']) {
$t['status'] = 'passed';
}
$deprecated = $test->getTestResultObject()->deprecatedFeatures();
$t['deprecated'] = array_diff($deprecated, $this->deprecated);
$t['assertions'] = $test->getNumAssertions();
$t['output'] = ob_get_contents();
$t['time'] = $time;
$this->deprecated = $deprecated;
$this->test(null);
ob_end_clean();
}