'twig_theme_test_filter',
'#quote' => [
'content' => ['#markup' => 'You can only find truth with logic if you have already found truth without it.'],
'author' => ['#markup' => 'Gilbert Keith Chesterton'],
'date' => ['#markup' => '1874-1936'],
],
'#attributes' => [
'id' => 'quotes',
'checked' => TRUE,
'class' => ['red', 'green', 'blue'],
],
];
$rendered = \Drupal::service('renderer')->renderRoot($filter_test);
$this->setRawContent($rendered);
$elements = [
[
'expected' => '
Marked-up:
You can only find truth with logic if you have already found truth without it.
',
'message' => '"Marked-up quote" was successfully rendered.',
],
[
'expected' => '
All attributes:
',
'message' => 'All attributes printed.',
],
[
'expected' => '
Class attributes in front, remainder at the back:
',
'message' => 'Class attributes printed in the front, the rest in the back.',
],
[
'expected' => '
Class attributes in back, remainder at the front:
',
'message' => 'Class attributes printed in the back, the rest in the front.',
],
[
'expected' => '
Class attributes only:
',
'message' => 'Class attributes only printed.',
],
[
'expected' => '
Without boolean attribute.
',
'message' => 'Boolean attribute printed in the front.',
],
[
'expected' => '
Without string attribute.
',
'message' => 'Without string attribute in the front.',
],
[
'expected' => '
Without id and class attributes.
',
'message' => 'Attributes printed without id and class attributes.',
],
[
'expected' => '
All attributes again.
',
'message' => 'All attributes printed again.',
],
[
'expected' => '
ID and class. Having the same ID twice is not valid markup but we want to make sure the filter doesn\'t use \Drupal\Component\Utility\Html::getUniqueId().
',
'message' => 'Class and ID filtered.',
],
[
'expected' => '
Rendered author string length: 24.
',
'message' => 'Render filter string\'s length.',
],
];
foreach ($elements as $element) {
$this->assertRaw($element['expected'], $element['message']);
}
}
}