Same name and namespace in other branches
  1. 8.x-1.x tests/src/Functional/EntityCloneDateFormatTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneDateFormatTest::testDateFormatEntityClone() 1 comment

Test date format entity clone.

File

tests/src/Functional/EntityCloneDateFormatTest.php, line 62

Class

EntityCloneDateFormatTest
Create a date format and test a clone.

Namespace

Drupal\Tests\entity_clone\Functional

Code

public function testDateFormatEntityClone() {
    $edit = [
        'label' => 'Test date format for clone',
        'id' => 'test_date_format_for_clone',
        'date_format_pattern' => 'Y m d',
    ];
    $this->drupalGet("admin/config/regional/date-time/formats/add");
    $this->submitForm($edit, $this->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->drupalGet('entity_clone/date_format/' . $date_format->id());
    $this->submitForm($edit, $this->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.');
}