function ConfigMapperManagerTest::getNestedElement

Same name in other branches
  1. 9 core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php \Drupal\Tests\config_translation\Unit\ConfigMapperManagerTest::getNestedElement()
  2. 8.9.x core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php \Drupal\Tests\config_translation\Unit\ConfigMapperManagerTest::getNestedElement()
  3. 10 core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php \Drupal\Tests\config_translation\Unit\ConfigMapperManagerTest::getNestedElement()

Returns a mocked nested schema element.

Parameters

array $elements: An array of simple schema elements.

Return value

\Drupal\Core\Config\Schema\Mapping A nested schema element, containing the passed-in elements.

1 call to ConfigMapperManagerTest::getNestedElement()
ConfigMapperManagerTest::providerTestHasTranslatable in core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php
Provides data for ConfigMapperManager::testHasTranslatable()

File

core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php, line 174

Class

ConfigMapperManagerTest
Tests the functionality provided by configuration translation mapper manager.

Namespace

Drupal\Tests\config_translation\Unit

Code

protected static function getNestedElement(array $elements) {
    // ConfigMapperManager::findTranslatable() checks for
    // \Drupal\Core\TypedData\TraversableTypedDataInterface, but mocking that
    // directly does not work, because we need to implement \IteratorAggregate
    // in order for getIterator() to be called. Therefore we need to mock
    // \Drupal\Core\Config\Schema\ArrayElement, but that is abstract, so we
    // need to mock one of the subclasses of it.
    $nested_element = (new Prophet())->prophesize(Mapping::class);
    $nested_element->getIterator()
        ->shouldBeCalledTimes(1)
        ->willReturn(new \ArrayIterator($elements));
    return $nested_element->reveal();
}

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