function ImageFieldTestBase::previewNodeImage
Same name in other branches
- 8.9.x core/modules/image/src/Tests/ImageFieldTestBase.php \Drupal\image\Tests\ImageFieldTestBase::previewNodeImage()
- 8.9.x core/modules/image/tests/src/Functional/ImageFieldTestBase.php \Drupal\Tests\image\Functional\ImageFieldTestBase::previewNodeImage()
- 10 core/modules/image/tests/src/Functional/ImageFieldTestBase.php \Drupal\Tests\image\Functional\ImageFieldTestBase::previewNodeImage()
- 11.x core/modules/image/tests/src/Functional/ImageFieldTestBase.php \Drupal\Tests\image\Functional\ImageFieldTestBase::previewNodeImage()
Preview an image in a node.
Parameters
\Drupal\Core\Image\ImageInterface $image: A file object representing the image to upload.
string $field_name: Name of the image field the image should be attached to.
string $type: The type of node to create.
3 calls to ImageFieldTestBase::previewNodeImage()
- ImageFieldDisplayTest::testImageLoadingAttribute in core/
modules/ image/ tests/ src/ Functional/ ImageFieldDisplayTest.php - Tests for image loading attribute settings.
- ImageFieldDisplayTest::_testImageFieldFormatters in core/
modules/ image/ tests/ src/ Functional/ ImageFieldDisplayTest.php - Tests image formatters on node display.
- ResponsiveImageFieldDisplayTest::assertResponsiveImageFieldFormattersLink in core/
modules/ responsive_image/ tests/ src/ Functional/ ResponsiveImageFieldDisplayTest.php - Tests responsive image formatters linked to the file or node.
File
-
core/
modules/ image/ tests/ src/ Functional/ ImageFieldTestBase.php, line 86
Class
- ImageFieldTestBase
- This class provides methods specifically for testing Image's field handling.
Namespace
Drupal\Tests\image\FunctionalCode
public function previewNodeImage($image, $field_name, $type) {
$edit = [
'title[0][value]' => $this->randomMachineName(),
];
$edit['files[' . $field_name . '_0]'] = \Drupal::service('file_system')->realpath($image->uri);
$this->drupalGet('node/add/' . $type);
$this->submitForm($edit, 'Preview');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.