function 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 170  
Class
- ConfigMapperManagerTest
 - Tests the functionality provided by configuration translation mapper manager.
 
Namespace
Drupal\Tests\config_translation\UnitCode
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')
    ->willReturn(new \ArrayIterator($elements));
  return $nested_element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.