Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ThemeControllerTest.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
16  public function testUploadJsAction()
17  {
18  $name = 'simple-js-file.js';
19  $this->createUploadFixture($name);
20  $theme = $this->_objectManager->create(\Magento\Framework\View\Design\ThemeInterface::class)
21  ->getCollection()
22  ->getFirstItem();
23 
24  $this->getRequest()->setPostValue('id', $theme->getId());
25  $this->dispatch('backend/admin/system_design_theme/uploadjs');
26  $output = $this->getResponse()->getBody();
27  $this->assertContains('"error":false', $output);
28  $this->assertContains($name, $output);
29  }
30 
37  private function createUploadFixture($name)
38  {
40  $filesystem = $this->_objectManager->get(\Magento\Framework\Filesystem::class);
41  $tmpDir = $filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
42  $subDir = str_replace('\\', '_', __CLASS__);
43  $tmpDir->create($subDir);
44  $target = $tmpDir->getAbsolutePath("{$subDir}/{$name}");
45  copy(__DIR__ . "/_files/{$name}", $target);
46  $_FILES = [
47  'js_files_uploader' => [
48  'name' => 'simple-js-file.js',
49  'type' => 'application/x-javascript',
50  'tmp_name' => $target,
51  'error' => '0',
52  'size' => '28',
53  ],
54  ];
55  }
56 }
defined('TESTS_BP')||define('TESTS_BP' __DIR__
Definition: _bootstrap.php:60
$target
Definition: skip.phtml:8
$theme
$filesystem
if(!isset($_GET['name'])) $name
Definition: log.php:14