public function CustomFormattersGeneralTest::testFormatterTypeFormatterPreset in Custom Formatters 8.3
Test the Formatter preset Engine.
@TODO - Add manual creation test.
File
- src/
Tests/ CustomFormattersGeneralTest.php, line 71
Class
- CustomFormattersGeneralTest
- Test general functionality.
Namespace
Drupal\custom_formatters\TestsCode
public function testFormatterTypeFormatterPreset() {
// Create a Custom formatter.
$this->formatter = $this
->createCustomFormatter([
'type' => 'formatter_preset',
'data' => [
'formatter' => 'text_trimmed',
'settings' => [
'trim_length' => 10,
],
],
]);
// Set the formatter active on the Body field.
$this
->setCustomFormatter($this->formatter
->id(), 'body', 'article');
// Ensure Formatter rendered correctly.
$this
->drupalGet($this->node
->toUrl());
// We substring to a length of 7 characters instead of 10 characters as the
// formatter will include the starting HTML paragraph tag in the character
// count.
$this
->assert(!strstr($this->content, $this->node
->get('body')[0]->value) && strstr($this->content, substr($this->node
->get('body')[0]->value, 0, 7)), t('Custom formatter output found.'));
}