Same name in other branches
- 2.x tests/src/Functional/EntityCloneImageStyleTest.php \Drupal\Tests\entity_clone\Functional\EntityCloneImageStyleTest::testImageStyleEntityClone()
Test image style entity clone.
File
-
tests/
src/ Functional/ EntityCloneImageStyleTest.php, line 62
Class
- EntityCloneImageStyleTest
- Create an image style and test a clone.
Namespace
Drupal\Tests\entity_clone\FunctionalCode
public function testImageStyleEntityClone() {
$edit = [
'label' => 'Test image style for clone',
'name' => 'test_image_style_for_clone',
];
$this->drupalGet("admin/config/media/image-styles/add");
$this->submitForm($edit, $this->t('Create new style'));
$image_styles = \Drupal::entityTypeManager()->getStorage('image_style')
->loadByProperties([
'name' => $edit['name'],
]);
$image_style = reset($image_styles);
$edit = [
'id' => 'test_iamge_style_cloned',
'label' => 'Test image_style cloned',
];
$this->drupalGet('entity_clone/image_style/' . $image_style->id());
$this->submitForm($edit, $this->t('Clone'));
$image_styles = \Drupal::entityTypeManager()->getStorage('image_style')
->loadByProperties([
'name' => $edit['id'],
]);
$image_style = reset($image_styles);
$this->assertInstanceOf(ImageStyle::class, $image_style, 'Test image style cloned found in database.');
$edit = [
'id' => 'test_image_style_clone_with_a_really_long_name_that_is_longer_than_the_max_length',
'label' => 'Test image style clone with a really long name that is longer than the max length',
];
$this->drupalGet('entity_clone/image_style/' . $image_style->id());
$this->submitForm($edit, $this->t('Clone'));
$this->assertSession()
->pageTextContains('New Id cannot be longer than 64 characters');
}