class LogToReportMigration
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@internal This class is not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\TextUI\XmlConfiguration\LogToReportMigration implements \PHPUnit\TextUI\XmlConfiguration\Migration
Expanded class hierarchy of LogToReportMigration
File
-
vendor/
phpunit/ phpunit/ src/ TextUI/ Configuration/ Xml/ Migration/ Migrations/ LogToReportMigration.php, line 22
Namespace
PHPUnit\TextUI\XmlConfigurationView source
abstract class LogToReportMigration implements Migration {
/**
* @throws MigrationException
*/
public function migrate(DOMDocument $document) : void {
$coverage = $document->getElementsByTagName('coverage')
->item(0);
if (!$coverage instanceof DOMElement) {
throw new MigrationException('Unexpected state - No coverage element');
}
$logNode = $this->findLogNode($document);
if ($logNode === null) {
return;
}
$reportChild = $this->toReportFormat($logNode);
$report = $coverage->getElementsByTagName('report')
->item(0);
if ($report === null) {
$report = $coverage->appendChild($document->createElement('report'));
}
$report->appendChild($reportChild);
$logNode->parentNode
->removeChild($logNode);
}
protected function migrateAttributes(DOMElement $src, DOMElement $dest, array $attributes) : void {
foreach ($attributes as $attr) {
if (!$src->hasAttribute($attr)) {
continue;
}
$dest->setAttribute($attr, $src->getAttribute($attr));
$src->removeAttribute($attr);
}
}
protected abstract function forType() : string;
protected abstract function toReportFormat(DOMElement $logNode) : DOMElement;
private function findLogNode(DOMDocument $document) : ?DOMElement {
$logNode = (new DOMXPath($document))->query(sprintf('//logging/log[@type="%s"]', $this->forType()))
->item(0);
if (!$logNode instanceof DOMElement) {
return null;
}
return $logNode;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
LogToReportMigration::findLogNode | private | function | |||
LogToReportMigration::forType | abstract protected | function | 6 | ||
LogToReportMigration::migrate | public | function | Overrides Migration::migrate | ||
LogToReportMigration::migrateAttributes | protected | function | |||
LogToReportMigration::toReportFormat | abstract protected | function | 6 |