comparison core/modules/image/src/Tests/ImageFieldDisplayTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
310 // 1, so we need to make sure the file widget prevents these notices by 310 // 1, so we need to make sure the file widget prevents these notices by
311 // providing all settings, even if they are not used. 311 // providing all settings, even if they are not used.
312 // @see FileWidget::formMultipleElements(). 312 // @see FileWidget::formMultipleElements().
313 $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', ['cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED], t('Save field settings')); 313 $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $field_name . '/storage', ['cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED], t('Save field settings'));
314 $edit = [ 314 $edit = [
315 'files[' . $field_name . '_1][]' => drupal_realpath($test_image->uri), 315 'files[' . $field_name . '_1][]' => \Drupal::service('file_system')->realpath($test_image->uri),
316 ]; 316 ];
317 $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save')); 317 $this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
318 // Add the required alt text. 318 // Add the required alt text.
319 $this->drupalPostForm(NULL, [$field_name . '[1][alt]' => $alt], t('Save')); 319 $this->drupalPostForm(NULL, [$field_name . '[1][alt]' => $alt], t('Save'));
320 $this->assertText(format_string('Article @title has been updated.', ['@title' => $node->getTitle()])); 320 $this->assertText(format_string('Article @title has been updated.', ['@title' => $node->getTitle()]));
321 321
322 // Assert ImageWidget::process() calls FieldWidget::process(). 322 // Assert ImageWidget::process() calls FieldWidget::process().
323 $this->drupalGet('node/' . $node->id() . '/edit'); 323 $this->drupalGet('node/' . $node->id() . '/edit');
324 $edit = [ 324 $edit = [
325 'files[' . $field_name . '_2][]' => drupal_realpath($test_image->uri), 325 'files[' . $field_name . '_2][]' => \Drupal::service('file_system')->realpath($test_image->uri),
326 ]; 326 ];
327 $this->drupalPostAjaxForm(NULL, $edit, $field_name . '_2_upload_button'); 327 $this->drupalPostAjaxForm(NULL, $edit, $field_name . '_2_upload_button');
328 $this->assertNoRaw('<input multiple type="file" id="edit-' . strtr($field_name, '_', '-') . '-2-upload" name="files[' . $field_name . '_2][]" size="22" class="js-form-file form-file">'); 328 $this->assertNoRaw('<input multiple type="file" id="edit-' . strtr($field_name, '_', '-') . '-2-upload" name="files[' . $field_name . '_2][]" size="22" class="js-form-file form-file">');
329 $this->assertRaw('<input multiple type="file" id="edit-' . strtr($field_name, '_', '-') . '-3-upload" name="files[' . $field_name . '_3][]" size="22" class="js-form-file form-file">'); 329 $this->assertRaw('<input multiple type="file" id="edit-' . strtr($field_name, '_', '-') . '-3-upload" name="files[' . $field_name . '_3][]" size="22" class="js-form-file form-file">');
330 } 330 }
355 $images = $this->drupalGetTestFiles('image'); 355 $images = $this->drupalGetTestFiles('image');
356 $alt = $this->randomString(512); 356 $alt = $this->randomString(512);
357 $title = $this->randomString(1024); 357 $title = $this->randomString(1024);
358 $edit = [ 358 $edit = [
359 // Get the path of the 'image-test.png' file. 359 // Get the path of the 'image-test.png' file.
360 'files[settings_default_image_uuid]' => drupal_realpath($images[0]->uri), 360 'files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($images[0]->uri),
361 'settings[default_image][alt]' => $alt, 361 'settings[default_image][alt]' => $alt,
362 'settings[default_image][title]' => $title, 362 'settings[default_image][title]' => $title,
363 ]; 363 ];
364 $this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings')); 364 $this->drupalPostForm("admin/structure/types/manage/article/fields/node.article.$field_name/storage", $edit, t('Save field settings'));
365 // Clear field definition cache so the new default image is detected. 365 // Clear field definition cache so the new default image is detected.
424 $private_field_name = strtolower($this->randomMachineName()); 424 $private_field_name = strtolower($this->randomMachineName());
425 $this->createImageField($private_field_name, 'article', ['uri_scheme' => 'private']); 425 $this->createImageField($private_field_name, 'article', ['uri_scheme' => 'private']);
426 // Add a default image to the new field. 426 // Add a default image to the new field.
427 $edit = [ 427 $edit = [
428 // Get the path of the 'image-test.gif' file. 428 // Get the path of the 'image-test.gif' file.
429 'files[settings_default_image_uuid]' => drupal_realpath($images[2]->uri), 429 'files[settings_default_image_uuid]' => \Drupal::service('file_system')->realpath($images[2]->uri),
430 'settings[default_image][alt]' => $alt, 430 'settings[default_image][alt]' => $alt,
431 'settings[default_image][title]' => $title, 431 'settings[default_image][title]' => $title,
432 ]; 432 ];
433 $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $private_field_name . '/storage', $edit, t('Save field settings')); 433 $this->drupalPostForm('admin/structure/types/manage/article/fields/node.article.' . $private_field_name . '/storage', $edit, t('Save field settings'));
434 // Clear field definition cache so the new default image is detected. 434 // Clear field definition cache so the new default image is detected.