public function EntityCloneDateFormatTest::testDateFormatEntityClone in Entity Clone 8
Test date format entity clone.
File
- tests/
src/ Functional/ EntityCloneDateFormatTest.php, line 58
Class
- EntityCloneDateFormatTest
- Create a date format and test a clone.
Namespace
Drupal\Tests\entity_clone\FunctionalCode
public function testDateFormatEntityClone() {
$edit = [
'label' => 'Test date format for clone',
'id' => 'test_date_format_for_clone',
'date_format_pattern' => 'Y m d',
];
$this
->drupalPostForm("admin/config/regional/date-time/formats/add", $edit, t('Add format'));
$date_formats = \Drupal::entityTypeManager()
->getStorage('date_format')
->loadByProperties([
'id' => $edit['id'],
]);
$date_format = reset($date_formats);
$edit = [
'id' => 'test_date_format_cloned',
'label' => 'Test date format cloned',
];
$this
->drupalPostForm('entity_clone/date_format/' . $date_format
->id(), $edit, t('Clone'));
$date_formats = \Drupal::entityTypeManager()
->getStorage('date_format')
->loadByProperties([
'id' => $edit['id'],
]);
$date_format = reset($date_formats);
$this
->assertInstanceOf(DateFormat::class, $date_format, 'Test date format cloned found in database.');
}