public function ImageWidgetCropTest::testCropUi in Image Widget Crop 8.2
Test Image Widget Crop UI.
File
- tests/
src/ FunctionalJavascript/ ImageWidgetCropTest.php, line 65
Class
- ImageWidgetCropTest
- Minimal test case for the image_widget_crop module.
Namespace
Drupal\Tests\image_widget_crop\FunctionalJavascriptCode
public function testCropUi() {
// Test that when a crop has more than one usage we have a warning.
$this
->createImageField('field_image_crop_test', 'crop_test', 'image_widget_crop', [], [], [
'crop_list' => [
'crop_16_9' => 'crop_16_9',
],
'crop_types_required' => [],
]);
$this
->drupalGetTestFiles('image');
$this
->drupalGet('node/add/crop_test');
$edit = [
'title[0][value]' => $this
->randomMachineName(),
];
$this
->getSession()
->getPage()
->attachFileToField('files[field_image_crop_test_0]', $this->container
->get('file_system')
->realpath('public://image-test.jpg'));
$this
->drupalPostForm(NULL, $edit, 'Save');
$node = Node::create([
'title' => '2nd node using it',
'type' => 'crop_test',
'field_image_crop_test' => 1,
'alt' => $this
->randomMachineName(),
]);
$node
->save();
/** @var \Drupal\file\FileUsage\FileUsageInterface $usage */
$usage = \Drupal::service('file.usage');
$usage
->add(\Drupal::service('entity_type.manager')
->getStorage('file')
->load(1), 'image_widget_crop', 'node', $node
->id());
$this
->drupalGet('node/1/edit');
$this
->assertSession()
->responseContains(t('This crop definition affects more usages of this image'));
}