You are here

public function MarkupInterfaceComparatorTest::dataSetProvider in Drupal 8

Same name and namespace in other branches
  1. 9 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 57

Class

MarkupInterfaceComparatorTest
Tests \Drupal\TestTools\Comparator\MarkupInterfaceComparator.

Namespace

Drupal\KernelTests\Core\Test\Comparator

Code

public 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,
      Notice::class,
    ],
    'stdClass vs TranslatableMarkup' => [
      (object) [
        'goldfinger',
      ],
      new TranslatableMarkup('goldfinger'),
      FALSE,
      FALSE,
    ],
    'string vs string, equal' => [
      'goldfinger',
      'goldfinger',
      FALSE,
      TRUE,
    ],
  ];
}