public function QuickEditImageControllerTest::uploadImage in Drupal 8
Uploads an image using the image module's Quick Edit route.
Parameters
object $image: The image to upload.
int $nid: The target node ID.
string $field_name: The target field machine name.
string $langcode: The langcode to use when setting the field's value.
2 calls to QuickEditImageControllerTest::uploadImage()
- QuickEditImageControllerTest::testInvalidUpload in core/
modules/ image/ tests/ src/ Functional/ QuickEditImageControllerTest.php - Tests that uploading a invalid image does not work.
- QuickEditImageControllerTest::testValidImageUpload in core/
modules/ image/ tests/ src/ Functional/ QuickEditImageControllerTest.php - Tests that uploading a valid image works.
File
- core/
modules/ image/ tests/ src/ Functional/ QuickEditImageControllerTest.php, line 182
Class
- QuickEditImageControllerTest
- Tests the endpoints used by the "image" in-place editor.
Namespace
Drupal\Tests\image\FunctionalCode
public function uploadImage($image, $nid, $field_name, $langcode) {
$filepath = $this->container
->get('file_system')
->realpath($image->uri);
$path = 'quickedit/image/upload/node/' . $nid . '/' . $field_name . '/' . $langcode . '/default';
$this
->prepareRequest();
$client = $this
->getSession()
->getDriver()
->getClient();
$client
->request('POST', $this
->buildUrl($path, []), [], [
'files[image]' => $filepath,
]);
}