class MarkupInterfaceComparator in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php \Drupal\TestTools\Comparator\MarkupInterfaceComparator
- 9 core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php \Drupal\TestTools\Comparator\MarkupInterfaceComparator
Compares MarkupInterface objects for equality.
Hierarchy
- class \Drupal\TestTools\Comparator\MarkupInterfaceComparator extends \SebastianBergmann\Comparator\Comparator
Expanded class hierarchy of MarkupInterfaceComparator
3 files declare their use of MarkupInterfaceComparator
- BrowserTestBase.php in core/
tests/ Drupal/ Tests/ BrowserTestBase.php - KernelTestBase.php in core/
tests/ Drupal/ KernelTests/ KernelTestBase.php - MarkupInterfaceComparatorTest.php in core/
tests/ Drupal/ KernelTests/ Core/ Test/ Comparator/ MarkupInterfaceComparatorTest.php
File
- core/
tests/ Drupal/ TestTools/ Comparator/ MarkupInterfaceComparator.php, line 11
Namespace
Drupal\TestTools\ComparatorView source
class MarkupInterfaceComparator extends Comparator {
/**
* {@inheritdoc}
*/
public function accepts($expected, $actual) {
// If at least one argument is a MarkupInterface object, we take over and
// convert to strings before comparing.
return $expected instanceof MarkupInterface && $actual instanceof MarkupInterface || $expected instanceof MarkupInterface && is_scalar($actual) || is_scalar($expected) && $actual instanceof MarkupInterface;
}
/**
* {@inheritdoc}
*/
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);
}
}