public function AddressPlainFormatterTest::testAddressPlainThemeHookSuggestions in Address 8
Tests the theme hook suggestions.
See also
\Drupal\Tests\node\Functional\NodeTemplateSuggestionsTest
File
- tests/
src/ Kernel/ Formatter/ AddressPlainFormatterTest.php, line 68
Class
- AddressPlainFormatterTest
- Tests the address_plain formatter.
Namespace
Drupal\Tests\address\Kernel\FormatterCode
public function testAddressPlainThemeHookSuggestions() {
foreach ([
'full',
'my_custom_view_mode',
] as $view_mode) {
// Simulate themeing of the address test entity.
$variables['theme_hook_original'] = 'address_plain';
$variables['view_mode'] = $view_mode;
$variables['address'] = $this->entity->{$this->fieldName};
$suggestions = \Drupal::moduleHandler()
->invokeAll('theme_suggestions_address_plain', [
$variables,
]);
$expected_suggestions = [
// Hook __ entity_type __ view_mode.
'address_plain__entity_test__' . $view_mode,
// Hook __ entity_type __ bundle.
'address_plain__entity_test__entity_test',
// Hook __ entity_type __ bundle __ view_mode.
'address_plain__entity_test__entity_test__' . $view_mode,
// Hook __ field_name.
'address_plain__' . $this->fieldName,
// Hook __ entity_type __ field_name.
'address_plain__entity_test__' . $this->fieldName,
// Hook __ entity_type __ field_name __ bundle.
'address_plain__entity_test__' . $this->fieldName . '__entity_test',
];
$this
->assertEquals($expected_suggestions, $suggestions, 'Unexpected theme suggestions for ' . $view_mode);
}
}