MarkupInterfaceComparator.php in Drupal 9
File
core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php
View source
<?php
namespace Drupal\TestTools\Comparator;
use Drupal\Component\Render\MarkupInterface;
use SebastianBergmann\Comparator\Comparator;
class MarkupInterfaceComparator extends Comparator {
public function accepts($expected, $actual) {
return $expected instanceof MarkupInterface && $actual instanceof MarkupInterface || $expected instanceof MarkupInterface && is_scalar($actual) || is_scalar($expected) && $actual instanceof MarkupInterface;
}
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = FALSE, $ignoreCase = FALSE) {
$expected_safe = (string) $expected;
$actual_safe = (string) $actual;
$comparator = $this->factory
->getComparatorFor($expected_safe, $actual_safe);
$comparator
->assertEquals($expected_safe, $actual_safe, $delta, $canonicalize, $ignoreCase);
}
}