public function DateRecurBasicFormatterTest::testFormatterSettingsSummary in Recurring Dates Field 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterSettingsSummary()
- 3.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterSettingsSummary()
- 3.1.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterSettingsSummary()
Tests setting summary.
File
- tests/
src/ Kernel/ DateRecurBasicFormatterTest.php, line 195
Class
- DateRecurBasicFormatterTest
- Tests date recur formatter.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testFormatterSettingsSummary() {
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $efm */
$efm = $this->container
->get('entity_field.manager');
$definitions = $efm
->getBaseFieldDefinitions('dr_entity_test');
$separator = $this
->randomMachineName(4);
$dateFormatId = $this->dateFormat
->id();
$options = [
'configuration' => [
'label' => 'above',
'type' => 'date_recur_basic_formatter',
'settings' => [
'format_type' => $dateFormatId,
'occurrence_format_type' => $dateFormatId,
'same_end_date_format_type' => $dateFormatId,
'interpreter' => $this->interpreter
->id(),
'count_per_item' => TRUE,
'separator' => $separator,
'show_next' => 5,
],
],
'field_definition' => $definitions['dr'],
'prepare' => TRUE,
'view_mode' => 'full',
];
/** @var \Drupal\Core\Field\FormatterPluginManager $fieldFormatterManager */
$fieldFormatterManager = $this->container
->get('plugin.manager.field.formatter');
$instance = $fieldFormatterManager
->getInstance($options);
$summary = $instance
->settingsSummary();
// Generate after summary to prevent random test failures.
$now = new \DateTime('now');
$formatSample = $now
->format($this->dateFormat
->getPattern());
$this
->assertEquals('Format: ' . $formatSample, $summary[0]);
$this
->assertEquals('Separator: <em class="placeholder">' . $separator . '</em>', $summary[1]);
$this
->assertEquals('Show maximum of 5 occurrences per field item', $summary[2]);
}