public function EntityCloneImageStyleTest::testImageStyleEntityClone in Entity Clone 8
Test image style entity clone.
File
- tests/
src/ Functional/ EntityCloneImageStyleTest.php, line 58
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
->drupalPostForm("admin/config/media/image-styles/add", $edit, 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
->drupalPostForm('entity_clone/image_style/' . $image_style
->id(), $edit, 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
->drupalPostForm('entity_clone/image_style/' . $image_style
->id(), $edit, t('Clone'));
$this
->assertText('New Id cannot be longer than 64 characters');
}