public function DropzoneJsUploadControllerTest::testDropzoneJsUploadController in DropzoneJS 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/DropzoneJsUploadControllerTest.php \Drupal\Tests\dropzonejs\Kernel\DropzoneJsUploadControllerTest::testDropzoneJsUploadController()
Test that DropzoneJS correctly handles uploads.
File
- tests/
src/ Kernel/ DropzoneJsUploadControllerTest.php, line 73
Class
- DropzoneJsUploadControllerTest
- Tests DropzoneJS upload controller.
Namespace
Drupal\Tests\dropzonejs\KernelCode
public function testDropzoneJsUploadController() {
$this->container
->get('router.builder')
->rebuild();
$language = ConfigurableLanguage::createFromLangcode('ru');
$language
->save();
$this
->config('system.site')
->set('default_langcode', $language
->getId())
->save();
$unicode_emoticon = json_decode('"\\uD83D\\uDE0E"');
$uploaded_file = new UploadedFile($this->tmpFile, "{$this->testfilePrefix}controller-Капля a,A;1{$unicode_emoticon}.jpg");
$file_bag = new FileBag();
$file_bag
->set('file', $uploaded_file);
$request = new Request();
$request->files = $file_bag;
$upload_handler = $this->container
->get('dropzonejs.upload_handler');
$controller = new UploadController($upload_handler, $request);
$controller_result = $controller
->handleUploads();
$this
->assertInstanceOf(JsonResponse::class, $controller_result);
$result = json_decode($controller_result
->getContent());
$result_file = $this->filesDir . '/' . $result->result;
$this
->assertStringEndsWith('-kaplya_aa1.jpg.txt', $result_file);
$this
->assertFileExists($result_file);
$this
->assertEquals(file_get_contents($result_file), $this->testfileData);
}