public function DateRecurBasicFormatterTest::testFormatterDependencies in Recurring Dates Field 3.x
Same name and namespace in other branches
- 8.2 tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterDependencies()
- 3.0.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterDependencies()
- 3.1.x tests/src/Kernel/DateRecurBasicFormatterTest.php \Drupal\Tests\date_recur\Kernel\DateRecurBasicFormatterTest::testFormatterDependencies()
Tests setting summary occurrence sample for different day.
File
- tests/
src/ Kernel/ DateRecurBasicFormatterTest.php, line 372
Class
- DateRecurBasicFormatterTest
- Tests date recur formatter.
Namespace
Drupal\Tests\date_recur\KernelCode
public function testFormatterDependencies() {
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $efm */
$efm = $this->container
->get('entity_field.manager');
$definitions = $efm
->getBaseFieldDefinitions('dr_entity_test');
$dateFormat1 = DateFormat::create([
'id' => $this
->randomMachineName(),
]);
$dateFormat1
->save();
$dateFormat2 = DateFormat::create([
'id' => $this
->randomMachineName(),
]);
$dateFormat2
->save();
$dateFormat3 = DateFormat::create([
'id' => $this
->randomMachineName(),
]);
$dateFormat3
->save();
$options = [
'configuration' => [
'label' => 'above',
'type' => 'date_recur_basic_formatter',
'settings' => [
'format_type' => $dateFormat1
->id(),
'occurrence_format_type' => $dateFormat2
->id(),
'same_end_date_format_type' => $dateFormat3
->id(),
'interpreter' => $this->interpreter
->id(),
'count_per_item' => FALSE,
'separator' => '-',
'show_next' => 10,
],
],
'field_definition' => $definitions['dr'],
'prepare' => TRUE,
'view_mode' => 'full',
];
/** @var \Drupal\Core\Field\FormatterPluginManager $fieldFormatterManager */
$fieldFormatterManager = $this->container
->get('plugin.manager.field.formatter');
/** @var \Drupal\date_recur\Plugin\Field\FieldFormatter\DateRecurBasicFormatter $instance */
$instance = $fieldFormatterManager
->getInstance($options);
$expectedConfigDependencies = [
'core.date_format.' . $dateFormat1
->id(),
'core.date_format.' . $dateFormat2
->id(),
'core.date_format.' . $dateFormat3
->id(),
'date_recur.interpreter.' . $this->interpreter
->id(),
];
sort($expectedConfigDependencies);
$this
->assertEquals($expectedConfigDependencies, $instance
->calculateDependencies()['config']);
}