Repository navigation
Increase code coverage #1625
Description
To-do list:
-
CssDocument::getFilteredAtIdentifierAndRule() -
CssDocument::isValidAtRuleToRender() -
AbstractHtmlProcessor::getHtml() -
CssInliner::generateStyleStringFromDeclarationsArrays()
Listing code paths that are not covered yet.
CssDocument::getFilteredAtIdentifierAndRule(): The guard clause probably can be covered with a test:
if ($rule->atRuleName() !== 'media') {
return null;
}CssDocument::isValidAtRuleToRender(): The default case probably can be covered with a test:
switch ($rule->atRuleName()) {
case 'media':
$result = false;
break;
case 'font-face':
$result = $rule instanceof CssRuleSet
&& $rule->getDeclarations('font-family') !== []
&& $rule->getDeclarations('src') !== [];
break;
default:
$result = true;
}AbstractHtmlProcessor::getHtml(): either cover with a test or replace with an assertion:
$html = $this->getDomDocument()->saveHTML($node);
if (!\is_string($html)) {
throw new \RuntimeException('`DOMDocument::saveHTML()` failed.', 1773018082);
}CssVariableEvaluator::replaceVariablesInPropertyValue(): PHP-version specific switch for Safe/notSafe, not coverable with only 1 PHP version:
$callable = \Closure::fromCallable([$this, 'getPropertyValueReplacement']);
if (\function_exists('Safe\\preg_replace_callback')) {
$result = preg_replace_callback($pattern, $callable, $propertyValue);
} else {
// @phpstan-ignore-next-line The safe version is only available in "thecodingmachine/safe" for PHP >= 8.1.
$result = \preg_replace_callback($pattern, $callable, $propertyValue);
}CssInliner::normalizeStyleAttributes(): PHP-version specific switch for Safe/notSafe, not coverable with only 1 PHP version:
$callback = \Closure::fromCallable([self::class, 'normalizePropertyNameCallback']);
if (\function_exists('Safe\\preg_replace_callback')) {
$normalizedOriginalStyle = preg_replace_callback($pattern, $callback, $node->getAttribute('style'));
} else {
// @phpstan-ignore-next-line The safe version is only available in "thecodingmachine/safe" for PHP >= 8.1.
$normalizedOriginalStyle = \preg_replace_callback($pattern, $callback, $node->getAttribute('style'));
\assert(\is_string($normalizedOriginalStyle));
}CssInliner::generateStyleStringFromDeclarationsArrays(): the exception probably can be covered with a test:
foreach ($combinedStyles as $attributeName => $attributeValue) {
$trimmedAttributeName = \trim($attributeName);
if ($trimmedAttributeName === '') {
throw new \UnexpectedValueException('An empty property name was encountered.', 1727046078);
}
$propertyName = DeclarationBlockParser::normalizePropertyName($trimmedAttributeName);
$propertyValue = \trim($attributeValue);
$style .= $propertyName . ': ' . $propertyValue . '; ';
}CssInliner::removeUnmatchablePseudoComponents(): PHP-version specific switch for Safe/notSafe, not coverable with only 1 PHP version:
$callback = \Closure::fromCallable([$this, 'replaceUnmatchableNotComponent']);
if (\function_exists('Safe\\preg_replace_callback')) {
$untrimmedSelectorWithoutNots = preg_replace_callback($pattern, $callback, ' ' . $selector);
} else {
// @phpstan-ignore-next-line The safe version is only available in "thecodingmachine/safe" for PHP >= 8.1.
$untrimmedSelectorWithoutNots = \preg_replace_callback($pattern, $callback, ' ' . $selector);
\assert(\is_string($untrimmedSelectorWithoutNots));
}
Activity