You are here

public function PrimitiveDataNormalizerTest::dataProviderPrimitiveData in Drupal 10

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

Data provider for testNormalize().

File

core/modules/serialization/tests/src/Unit/Normalizer/PrimitiveDataNormalizerTest.php, line 59

Class

PrimitiveDataNormalizerTest
@coversDefaultClass \Drupal\serialization\Normalizer\PrimitiveDataNormalizer @group serialization

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public function dataProviderPrimitiveData() {
  $data = [];
  $definition = DataDefinition::createFromDataType('string');
  $string = new StringData($definition, 'string');
  $string
    ->setValue('test');
  $data['string'] = [
    $string,
    'test',
  ];
  $definition = DataDefinition::createFromDataType('string');
  $string = new StringData($definition, 'string');
  $string
    ->setValue(NULL);
  $data['string-null'] = [
    $string,
    NULL,
  ];
  $definition = DataDefinition::createFromDataType('integer');
  $integer = new IntegerData($definition, 'integer');
  $integer
    ->setValue(5);
  $data['integer'] = [
    $integer,
    5,
  ];
  $definition = DataDefinition::createFromDataType('integer');
  $integer = new IntegerData($definition, 'integer');
  $integer
    ->setValue(NULL);
  $data['integer-null'] = [
    $integer,
    NULL,
  ];
  $definition = DataDefinition::createFromDataType('boolean');
  $boolean = new BooleanData($definition, 'boolean');
  $boolean
    ->setValue(TRUE);
  $data['boolean'] = [
    $boolean,
    TRUE,
  ];
  $definition = DataDefinition::createFromDataType('boolean');
  $boolean = new BooleanData($definition, 'boolean');
  $boolean
    ->setValue(NULL);
  $data['boolean-null'] = [
    $boolean,
    NULL,
  ];
  return $data;
}