You are here

public function NormalizerBaseTest::providerTestSupportsNormalization in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php \Drupal\Tests\serialization\Unit\Normalizer\NormalizerBaseTest::providerTestSupportsNormalization()

Data provider for testSupportsNormalization.

Return value

array An array of provider data for testSupportsNormalization.

File

core/modules/serialization/tests/src/Unit/Normalizer/NormalizerBaseTest.php, line 47
Contains \Drupal\Tests\serialization\Unit\Normalizer\NormalizerBaseTest.

Class

NormalizerBaseTest
@coversDefaultClass \Drupal\serialization\Normalizer\NormalizerBase @group serialization

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function providerTestSupportsNormalization() {
  return [
    // Something that is not an object should return FALSE immediately.
    [
      FALSE,
      [],
    ],
    // An object with no class set should return FALSE.
    [
      FALSE,
      new \stdClass(),
    ],
    // Set a supported Class.
    [
      TRUE,
      new \stdClass(),
      'stdClass',
    ],
    // Set a supported interface.
    [
      TRUE,
      new \RecursiveArrayIterator(),
      'RecursiveIterator',
    ],
    // Set a different class.
    [
      FALSE,
      new \stdClass(),
      'ArrayIterator',
    ],
    // Set a different interface.
    [
      FALSE,
      new \stdClass(),
      'RecursiveIterator',
    ],
  ];
}