You are here

public function FileUploadTest::testFileUploadNoExtensionSetting in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::testFileUploadNoExtensionSetting()
  2. 10 core/modules/jsonapi/tests/src/Functional/FileUploadTest.php \Drupal\Tests\jsonapi\Functional\FileUploadTest::testFileUploadNoExtensionSetting()

Tests using the file upload POST route no extension configured.

File

core/modules/jsonapi/tests/src/Functional/FileUploadTest.php, line 723

Class

FileUploadTest
Tests binary data file upload route.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testFileUploadNoExtensionSetting() {
  $this
    ->setUpAuthorization('POST');
  $this
    ->config('jsonapi.settings')
    ->set('read_only', FALSE)
    ->save(TRUE);
  $uri = Url::fromUri('base:' . static::$postUri);
  $this->field
    ->setSetting('file_extensions', '')
    ->save();
  $this
    ->rebuildAll();
  $response = $this
    ->fileRequest($uri, $this->testFileData, [
    'Content-Disposition' => 'filename="example.txt"',
  ]);
  $expected = $this
    ->getExpectedDocument(1, 'example.txt', TRUE);
  $this
    ->assertResponseData($expected, $response);
  $this
    ->assertFileExists('public://foobar/example.txt');
}