function MarkupInterfaceComparatorTest::dataSetProvider

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Test/Comparator/MarkupInterfaceComparatorTest.php \Drupal\KernelTests\Core\Test\Comparator\MarkupInterfaceComparatorTest::dataSetProvider()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Test/Comparator/MarkupInterfaceComparatorTest.php \Drupal\KernelTests\Core\Test\Comparator\MarkupInterfaceComparatorTest::dataSetProvider()
  3. 11.x core/tests/Drupal/KernelTests/Core/Test/Comparator/MarkupInterfaceComparatorTest.php \Drupal\KernelTests\Core\Test\Comparator\MarkupInterfaceComparatorTest::dataSetProvider()

Provides test data for the comparator.

Return value

array Each array entry has:

  • test expected value,
  • test actual value,
  • a bool indicating the expected return value of ::accepts,
  • a value indicating the expected result of ::assertEquals, TRUE if comparison should match, FALSE if error, or a class name of an object thrown.

File

core/tests/Drupal/KernelTests/Core/Test/Comparator/MarkupInterfaceComparatorTest.php, line 59

Class

MarkupInterfaceComparatorTest
Tests \Drupal\TestTools\Comparator\MarkupInterfaceComparator.

Namespace

Drupal\KernelTests\Core\Test\Comparator

Code

public static function dataSetProvider() {
    return [
        'FormattableMarkup vs FormattableMarkup, equal' => [
            new FormattableMarkup('GoldFinger', []),
            new FormattableMarkup('GoldFinger', []),
            TRUE,
            TRUE,
        ],
        'FormattableMarkup vs FormattableMarkup, not equal' => [
            new FormattableMarkup('GoldFinger', []),
            new FormattableMarkup('moonraker', []),
            TRUE,
            ComparisonFailure::class,
        ],
        'FormattableMarkup vs string, equal' => [
            new FormattableMarkup('GoldFinger', []),
            'GoldFinger',
            TRUE,
            TRUE,
        ],
        'string vs FormattableMarkup, equal' => [
            'GoldFinger',
            new FormattableMarkup('GoldFinger', []),
            TRUE,
            TRUE,
        ],
        'TranslatableMarkup vs FormattableMarkup, equal' => [
            new TranslatableMarkup('GoldFinger'),
            new FormattableMarkup('GoldFinger', []),
            TRUE,
            TRUE,
        ],
        'TranslatableMarkup vs string, not equal' => [
            new TranslatableMarkup('GoldFinger'),
            'moonraker',
            TRUE,
            ComparisonFailure::class,
        ],
        'TranslatableMarkup vs int, equal' => [
            new TranslatableMarkup('1234'),
            1234,
            TRUE,
            TRUE,
        ],
        'int vs TranslatableMarkup, equal' => [
            1234,
            new TranslatableMarkup('1234'),
            TRUE,
            TRUE,
        ],
        'FormattableMarkup vs array' => [
            new FormattableMarkup('GoldFinger', []),
            [
                'GoldFinger',
            ],
            FALSE,
            \InvalidArgumentException::class,
        ],
        'stdClass vs TranslatableMarkup' => [
            (object) [
                'GoldFinger',
            ],
            new TranslatableMarkup('GoldFinger'),
            FALSE,
            FALSE,
        ],
        'string vs string, equal' => [
            'GoldFinger',
            'GoldFinger',
            FALSE,
            \LogicException::class,
        ],
        'html string with tags vs html string with tags, equal' => [
            '<em class="placeholder">For Your Eyes</em> Only',
            '<em class="placeholder">For Your Eyes</em> Only',
            FALSE,
            \LogicException::class,
        ],
        'html string with tags vs plain string, not equal' => [
            '<em class="placeholder">For Your Eyes</em> Only',
            'For Your Eyes Only',
            FALSE,
            FALSE,
        ],
        'FormattableMarkup with placeholders vs FormattableMarkup with placeholders, equal' => [
            new FormattableMarkup('%placeholder Only', [
                '%placeholder' => 'For Your Eyes',
            ]),
            new FormattableMarkup('%placeholder Only', [
                '%placeholder' => 'For Your Eyes',
            ]),
            TRUE,
            TRUE,
        ],
        'FormattableMarkup with placeholders vs FormattableMarkup with placeholders, not equal' => [
            new FormattableMarkup('%placeholder Only', [
                '%placeholder' => 'For Your Eyes',
            ]),
            new FormattableMarkup('%placeholder Too', [
                '%placeholder' => 'For Your Eyes',
            ]),
            TRUE,
            FALSE,
        ],
    ];
}

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