<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Util\TestDox;
use function array_filter;
use function get_class;
use function implode;
use function strpos;
use DOMDocument;
use DOMElement;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Exception;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;
use PHPUnit\Framework\WarningTestCase;
use PHPUnit\Util\Printer;
use PHPUnit\Util\Test as TestUtil;
use ReflectionClass;
use ReflectionException;
use SebastianBergmann\RecursionContext\InvalidArgumentException;
use Throwable;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class XmlResultPrinter extends Printer implements TestListener
{
/**
* @var DOMDocument
*/
private $document;
/**
* @var DOMElement
*/
private $root;
/**
* @var NamePrettifier
*/
private $prettifier;
/**
* @var null|Throwable
*/
private $exception;
/**
* @param resource|string $out
*
* @throws Exception
*/
public function __construct($out = null)
{
$this->document = new DOMDocument('1.0', 'UTF-8');
$this->document->formatOutput = true;
$this->root = $this->document->createElement('tests');
$this->document->appendChild($this->root);
$this->prettifier = new NamePrettifier;
parent::__construct($out);
}
/**
* Flush buffer and close output.
*/
public function flush(): void
{
$this->write($this->document->saveXML());
parent::flush();
}
/**
* An error occurred.
*/
public function addError(Test $test, Throwable $t, float $time): void
{
$this->exception = $t;
}
/**
* A warning occurred.
*/
public function addWarning(Test $test, Warning $e, float $time): void
{
}
/**
* A failure occurred.
*/
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
{
$this->exception = $e;
}
/**
* Incomplete test.
*/
public function addIncompleteTest(Test $test, Throwable $t, float $time): void
{
}
/**
* Risky test.
*/
public function addRiskyTest(Test $test, Throwable $t, float $time): void
{
}
/**
* Skipped test.
*/
public function addSkippedTest(Test $test, Throwable $t, float $time): void
{
}
/**
* A test suite started.
*/
public function startTestSuite(TestSuite $suite): void
{
}
/**
* A test suite ended.
*/
public function endTestSuite(TestSuite $suite): void
{
}
/**
* A test started.
*/
public function startTest(Test $test): void
{
$this->exception = null;
}
/**
* A test ended.
*
* @throws InvalidArgumentException
*/
public function endTest(Test $test, float $time): void
{
if (!$test instanceof TestCase || $test instanceof WarningTestCase) {
return;
}
$groups = array_filter(
$test->getGroups(),
static function ($group)
{
return !($group === 'small' || $group === 'medium' || $group === 'large' || strpos($group, '__phpunit_') === 0);
},
);
$testNode = $this->document->createElement('test');
$testNode->setAttribute('className', get_class($test));
$testNode->setAttribute('methodName', $test->getName());
$testNode->setAttribute('prettifiedClassName', $this->prettifier->prettifyTestClass(get_class($test)));
$testNode->setAttribute('prettifiedMethodName', $this->prettifier->prettifyTestCase($test));
$testNode->setAttribute('status', (string) $test->getStatus());
$testNode->setAttribute('time', (string) $time);
$testNode->setAttribute('size', (string) $test->getSize());
$testNode->setAttribute('groups', implode(',', $groups));
foreach ($groups as $group) {
$groupNode = $this->document->createElement('group');
$groupNode->setAttribute('name', $group);
$testNode->appendChild($groupNode);
}
$annotations = TestUtil::parseTestMethodAnnotations(
get_class($test),
$test->getName(false),
);
foreach (['class', 'method'] as $type) {
foreach ($annotations[$type] as $annotation => $values) {
if ($annotation !== 'covers' && $annotation !== 'uses') {
continue;
}
foreach ($values as $value) {
$coversNode = $this->document->createElement($annotation);
$coversNode->setAttribute('target', $value);
$testNode->appendChild($coversNode);
}
}
}
foreach ($test->doubledTypes() as $doubledType) {
$testDoubleNode = $this->document->createElement('testDouble');
$testDoubleNode->setAttribute('type', $doubledType);
$testNode->appendChild($testDoubleNode);
}
$inlineAnnotations = TestUtil::getInlineAnnotations(get_class($test), $test->getName(false));
if (isset($inlineAnnotations['given'], $inlineAnnotations['when'], $inlineAnnotations['then'])) {
$testNode->setAttribute('given', $inlineAnnotations['given']['value']);
$testNode->setAttribute('givenStartLine', (string) $inlineAnnotations['given']['line']);
$testNode->setAttribute('when', $inlineAnnotations['when']['value']);
$testNode->setAttribute('whenStartLine', (string) $inlineAnnotations['when']['line']);
$testNode->setAttribute('then', $inlineAnnotations['then']['value']);
$testNode->setAttribute('thenStartLine', (string) $inlineAnnotations['then']['line']);
}
if ($this->exception !== null) {
if ($this->exception instanceof Exception) {
$steps = $this->exception->getSerializableTrace();
} else {
$steps = $this->exception->getTrace();
}
try {
$file = (new ReflectionClass($test))->getFileName();
// @codeCoverageIgnoreStart
} catch (ReflectionException $e) {
throw new Exception(
$e->getMessage(),
$e->getCode(),
$e,
);
}
// @codeCoverageIgnoreEnd
foreach ($steps as $step) {
if (isset($step['file']) && $step['file'] === $file) {
$testNode->setAttribute('exceptionLine', (string) $step['line']);
break;
}
}
$testNode->setAttribute('exceptionMessage', $this->exception->getMessage());
}
$this->root->appendChild($testNode);
}
}
At NFC Pay, we strive to provide a seamless and satisfactory experience with our services. This Refund Policy outlines the circumstances under which refunds may be issued for transactions made through our platform. Please read this policy carefully to understand your rights regarding refunds.
1. Eligibility for Refunds
Refunds may be considered under the following circumstances:
2. Non-Refundable Situations
Refunds will generally not be issued in the following situations:
3. Refund Process
To request a refund, please follow these steps:
4. Refund Exceptions
Certain transactions may be subject to specific terms and conditions, including non-refundable fees or charges. Please review the terms associated with each transaction carefully, as some fees may not be eligible for refunds.
5. Modifications to the Refund Policy
NFC Pay reserves the right to modify this Refund Policy at any time. Changes will be communicated through updates on our website and app, and the effective date will be updated accordingly. We encourage you to review this policy periodically to stay informed about our refund practices.
By using NFC Pay, you agree to this Refund Policy and understand the terms under which refunds may be issued. Our goal is to ensure a fair and transparent refund process, providing you with confidence and peace of mind when using our services.