class MarkupInterfaceComparator in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php \Drupal\TestTools\Comparator\MarkupInterfaceComparator
- 10 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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MarkupInterfaceComparator:: |
public | function | Returns whether the comparator can compare two values. | |
MarkupInterfaceComparator:: |
public | function | Asserts that two values are equal. |