function PrimitiveDataNormalizerTest::dataProviderPrimitiveData

Same name in other branches
  1. 9 core/modules/serialization/tests/src/Unit/Normalizer/PrimitiveDataNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\PrimitiveDataNormalizerTest::dataProviderPrimitiveData()
  2. 8.9.x core/modules/serialization/tests/src/Unit/Normalizer/PrimitiveDataNormalizerTest.php \Drupal\Tests\serialization\Unit\Normalizer\PrimitiveDataNormalizerTest::dataProviderPrimitiveData()
  3. 10 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 63

Class

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

Namespace

Drupal\Tests\serialization\Unit\Normalizer

Code

public static 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;
}

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