You are here

protected function ConfigMapperManagerTest::getNestedElement in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 164
Contains \Drupal\Tests\config_translation\Unit\ConfigMapperManagerTest.

Class

ConfigMapperManagerTest
Tests the functionality provided by configuration translation mapper manager.

Namespace

Drupal\Tests\config_translation\Unit

Code

protected 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 = $this
    ->getMockBuilder('Drupal\\Core\\Config\\Schema\\Mapping')
    ->disableOriginalConstructor()
    ->getMock();
  $nested_element
    ->expects($this
    ->once())
    ->method('getIterator')
    ->will($this
    ->returnValue(new \ArrayIterator($elements)));
  return $nested_element;
}