class MarkupInterfaceComparator

Same name in other branches
  1. 9 core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php \Drupal\TestTools\Comparator\MarkupInterfaceComparator
  2. 10 core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php \Drupal\TestTools\Comparator\MarkupInterfaceComparator
  3. 11.x core/tests/Drupal/TestTools/Comparator/MarkupInterfaceComparator.php \Drupal\TestTools\Comparator\MarkupInterfaceComparator

Compares MarkupInterface objects for equality.

Hierarchy

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\Comparator
View 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

Title Sort descending Modifiers Object type Summary
MarkupInterfaceComparator::accepts public function
MarkupInterfaceComparator::assertEquals public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.