|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Copyright 2011 Adobe |
4 |
| - * All Rights Reserved. |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
5 | 5 | */
|
6 | 6 | declare(strict_types=1);
|
7 | 7 |
|
|
15 | 15 | use Magento\Framework\Filesystem\DirectoryList;
|
16 | 16 | use Magento\Framework\Serialize\Serializer\Json;
|
17 | 17 | use Magento\TestFramework\TestCase\AbstractBackendController;
|
18 |
| -use Magento\Framework\App\Config\ScopeConfigInterface; |
19 | 18 |
|
20 | 19 | /**
|
21 | 20 | * Provide tests for admin product upload image action.
|
@@ -54,11 +53,6 @@ class UploadTest extends AbstractBackendController
|
54 | 53 | */
|
55 | 54 | private $config;
|
56 | 55 |
|
57 |
| - /** |
58 |
| - * @var ScopeConfigInterface |
59 |
| - */ |
60 |
| - private mixed $scopeConfig; |
61 |
| - |
62 | 56 | /**
|
63 | 57 | * @inheritdoc
|
64 | 58 | */
|
@@ -99,67 +93,6 @@ public function testUploadAction(array $file, array $expectation): void
|
99 | 93 | ));
|
100 | 94 | }
|
101 | 95 |
|
102 |
| - /** |
103 |
| - * Test upload image on admin product page. |
104 |
| - * |
105 |
| - * @dataProvider uploadActionDataProvider |
106 |
| - * @magentoDbIsolation enabled |
107 |
| - * @param array $file |
108 |
| - * @param array $expectation |
109 |
| - * @return void |
110 |
| - */ |
111 |
| - public function testUploadWithResizeAction(array $file, array $expectation): void |
112 |
| - { |
113 |
| - $this->copyFileToSysTmpDir($file); |
114 |
| - $this->scopeConfig->setValue( |
115 |
| - 'system/upload_configuration/max_width', |
116 |
| - 100 |
117 |
| - ); |
118 |
| - $this->scopeConfig->setValue( |
119 |
| - 'system/upload_configuration/max_height', |
120 |
| - 100 |
121 |
| - ); |
122 |
| - $this->getRequest()->setMethod($this->httpMethod); |
123 |
| - $this->dispatch($this->uri); |
124 |
| - $jsonBody = $this->serializer->unserialize($this->getResponse()->getBody()); |
125 |
| - $this->assertEquals($jsonBody['name'], $expectation['name']); |
126 |
| - $this->assertEquals($jsonBody['type'], $expectation['type']); |
127 |
| - $this->assertEquals($jsonBody['file'], $expectation['file']); |
128 |
| - $this->assertEquals($jsonBody['url'], $expectation['url']); |
129 |
| - $this->assertArrayNotHasKey('error', $jsonBody); |
130 |
| - $this->assertArrayNotHasKey('errorcode', $jsonBody); |
131 |
| - $this->assertTrue($this->mediaDirectory->isExist( |
132 |
| - $this->getFileAbsolutePath($expectation['tmp_media_path']) |
133 |
| - )); |
134 |
| - $dimensions = $this->getImageDimensions($this->getFileAbsolutePath($expectation['tmp_media_path'])); |
135 |
| - $this->assertLessThanOrEqual(100, $dimensions['width']); |
136 |
| - $this->assertLessThanOrEqual(100, $dimensions['height']); |
137 |
| - } |
138 |
| - |
139 |
| - /** |
140 |
| - * Fetch uploaded image dimension. |
141 |
| - * |
142 |
| - * @param $imagePath |
143 |
| - * @return array|false |
144 |
| - */ |
145 |
| - private function getImageDimensions($imagePath) |
146 |
| - { |
147 |
| - if (!file_exists($imagePath)) { |
148 |
| - return false; |
149 |
| - } |
150 |
| - |
151 |
| - $imageInfo = getimagesize($imagePath); |
152 |
| - |
153 |
| - if ($imageInfo === false) { |
154 |
| - return false; |
155 |
| - } |
156 |
| - |
157 |
| - return [ |
158 |
| - 'width' => $imageInfo[0], |
159 |
| - 'height' => $imageInfo[1], |
160 |
| - ]; |
161 |
| - } |
162 |
| - |
163 | 96 | /**
|
164 | 97 | * @return array
|
165 | 98 | */
|
|
0 commit comments