function 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[[api-linebreak]]
RecursiveContextualValidatorTest::testValidateProperty in core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
@covers ::validateProperty[[api-linebreak]]
RecursiveContextualValidatorTest::testValidatePropertyValue in core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
@covers ::validatePropertyValue[[api-linebreak]]

File

core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php, line 314

Class

RecursiveContextualValidatorTest
@coversDefaultClass \Drupal\Core\TypedData\Validation\RecursiveContextualValidator[[api-linebreak]] @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');
}

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