public function EntityReferenceFileUploadTest::testFileUpload in Drupal 10
Same name and namespace in other branches
- 8 core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFileUploadTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceFileUploadTest::testFileUpload()
- 9 core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFileUploadTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceFileUploadTest::testFileUpload()
Tests that the autocomplete input element does not cause ajax fatal.
File
- core/
modules/ field/ tests/ src/ Functional/ EntityReference/ EntityReferenceFileUploadTest.php, line 123
Class
- EntityReferenceFileUploadTest
- Tests an autocomplete widget with file upload.
Namespace
Drupal\Tests\field\Functional\EntityReferenceCode
public function testFileUpload() {
$user1 = $this
->drupalCreateUser([
'access content',
"create {$this->referencingType} content",
]);
$this
->drupalLogin($user1);
$test_file = current($this
->getTestFiles('text'));
$edit['files[file_field_0]'] = \Drupal::service('file_system')
->realpath($test_file->uri);
$this
->drupalGet('node/add/' . $this->referencingType);
$this
->submitForm($edit, 'Upload');
$this
->assertSession()
->statusCodeEquals(200);
$edit = [
'title[0][value]' => $this
->randomMachineName(),
'test_field[0][target_id]' => $this->nodeId,
];
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
}