private function AjaxControllerTest::initializeContainer in Sortableviews 8
Initializes container prior to test execution.
1 call to AjaxControllerTest::initializeContainer()
- AjaxControllerTest::setUp in tests/
src/ Unit/ Controller/ AjaxControllerTest.php
File
- tests/
src/ Unit/ Controller/ AjaxControllerTest.php, line 34
Class
- AjaxControllerTest
- @coversDefaultClass \Drupal\sortableviews\Controller\AjaxController @group sortableviews
Namespace
Drupal\Tests\sortableviews\Unit\ControllerCode
private function initializeContainer() {
$container = new ContainerBuilder();
// Mock the translation service.
$translation_service = $this
->createMock('Drupal\\Core\\StringTranslation\\TranslationInterface');
$container
->set('string_translation', $translation_service);
// Mock the renderer service.
$renderer = $this
->createMock('Drupal\\Core\\Render\\RendererInterface');
$render = 'something';
$renderer
->expects($this
->any())
->method('renderRoot')
->with()
->willReturnCallback(function (&$elements) use ($render) {
$elements['#attached'] = [];
return $render;
});
$container
->set('renderer', $renderer);
// Create the container.
\Drupal::setContainer($container);
}