public function FieldFieldTest::testAttachedRender in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/Handler/FieldFieldTest.php \Drupal\views\Tests\Handler\FieldFieldTest::testAttachedRender()
Tests that formatter's #attached assets are correctly preserved.
See also
\Drupal\views_test_formatter\Plugin\Field\FieldFormatter\AttachmentTestFormatter::viewElements()
File
- core/
modules/ views/ src/ Tests/ Handler/ FieldFieldTest.php, line 274 - Contains \Drupal\views\Tests\Handler\FieldFieldTest.
Class
- FieldFieldTest
- Provides some integration tests for the Field handler.
Namespace
Drupal\views\Tests\HandlerCode
public function testAttachedRender() {
$executable = Views::getView('test_field_field_attachment_test');
$executable
->execute();
// Check that the attachments added by AttachmentTestFormatter have been
// preserved in the render array.
$render = $executable->display_handler
->render();
$expected_attachments = [
'library' => [
'views/views.module',
],
];
foreach ($this->entities as $entity) {
$expected_attachments['library'][] = 'foo/fake_library';
$expected_attachments['drupalSettings']['AttachmentIntegerFormatter'][$entity
->id()] = $entity
->id();
}
$this
->assertEqual($expected_attachments, $render['#attached']);
}