You are here

protected function RecursiveContextualValidatorTest::buildExampleTypedDataWithProperties in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\Tests\Core\TypedData\RecursiveContextualValidatorTest::buildExampleTypedDataWithProperties()

Builds some example type data object.

Return value

\Drupal\Core\TypedData\TypedDataInterface|\PHPUnit\Framework\MockObject\MockObject

3 calls to RecursiveContextualValidatorTest::buildExampleTypedDataWithProperties()
RecursiveContextualValidatorTest::testPropertiesValidateWithMultipleLevels in core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
@covers ::validate
RecursiveContextualValidatorTest::testValidateProperty in core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
@covers ::validateProperty
RecursiveContextualValidatorTest::testValidatePropertyValue in core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
@covers ::validatePropertyValue

File

core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php, line 318
Contains \Drupal\Tests\Core\TypedData\RecursiveContextualValidatorTest.

Class

RecursiveContextualValidatorTest
@coversDefaultClass \Drupal\Core\TypedData\Validation\RecursiveContextualValidator @group typedData

Namespace

Drupal\Tests\Core\TypedData

Code

protected function buildExampleTypedDataWithProperties($subkey_value = NULL) {
  $subkey_value = $subkey_value ?: [
    'subkey1' => 'subvalue1',
    'subkey2' => 'subvalue2',
  ];
  $tree = [
    'value' => [
      'key1' => 'value1',
      'key2' => 'value2',
      'key_with_properties' => $subkey_value,
    ],
  ];
  $tree['properties'] = [
    'key1' => [
      'value' => 'value1',
    ],
    'key2' => [
      'value' => 'value2',
    ],
    'key_with_properties' => [
      'value' => $subkey_value ?: [
        'subkey1' => 'subvalue1',
        'subkey2' => 'subvalue2',
      ],
    ],
  ];
  $tree['properties']['key_with_properties']['properties']['subkey1'] = [
    'value' => $tree['properties']['key_with_properties']['value']['subkey1'],
  ];
  $tree['properties']['key_with_properties']['properties']['subkey2'] = [
    'value' => $tree['properties']['key_with_properties']['value']['subkey2'],
  ];
  return $this
    ->setupTypedData($tree, 'test_name');
}