Skip to content

Commit 0f78b9c

Browse files
Merge branch 'MC-41153' of https://github.com/magento-tsg/magento2ce into MC-41153
2 parents 6a3dc9b + 259693a commit 0f78b9c

File tree

4 files changed

+27
-24
lines changed

4 files changed

+27
-24
lines changed

app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Cms\Model\Wysiwyg\Images\Storage\Collection as StorageCollection;
99
use Magento\Framework\App\Filesystem\DirectoryList;
10+
use Magento\Framework\DataObject;
1011

1112
/**
1213
* @SuppressWarnings(PHPMD.LongVariable)
@@ -166,11 +167,9 @@ protected function setUp(): void
166167
)->method(
167168
'getPathInfo'
168169
)->willReturnCallback(
169-
170-
function ($path) {
171-
return pathinfo($path);
172-
}
173-
170+
function ($path) {
171+
return pathinfo($path);
172+
}
174173
);
175174

176175
$this->adapterFactoryMock = $this->createMock(\Magento\Framework\Image\AdapterFactory::class);
@@ -359,7 +358,10 @@ public function testGetDirsCollection($exclude, $include, $fileNames, $expectedR
359358
$collection = [];
360359
foreach ($fileNames as $filename) {
361360
/** @var \Magento\Framework\DataObject|\PHPUnit\Framework\MockObject\MockObject $objectMock */
362-
$objectMock = $this->createPartialMock(\Magento\Framework\DataObject::class, ['getFilename']);
361+
$objectMock = $this->getMockBuilder(DataObject::class)
362+
->addMethods(['getFilename'])
363+
->disableOriginalConstructor()
364+
->getMock();
363365
$objectMock->expects($this->any())
364366
->method('getFilename')
365367
->willReturn(self::STORAGE_ROOT_DIR . $filename);

app/code/Magento/Customer/Test/Unit/Model/FileProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public function testSaveTemporaryFileWithError()
324324
public function testMoveTemporaryFileUnableToCreateDirectory()
325325
{
326326
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
327-
$this->expectExceptionMessage('Unable to create directory customer/f/i');
327+
$this->expectExceptionMessage('Unable to create directory /f/i');
328328

329329
$filePath = '/filename.ext1';
330330

app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ImageTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\Theme\Test\Unit\Model\Design\Backend;
1010

11+
use Magento\Framework\Exception\LocalizedException;
1112
use Magento\Framework\Filesystem\Io\File as IoFile;
1213
use Magento\Theme\Model\Design\Backend\Image;
1314
use Magento\Framework\Filesystem\Directory\ReadFactory;
@@ -32,7 +33,7 @@ class ImageTest extends \PHPUnit\Framework\TestCase
3233
/**
3334
* @inheritdoc
3435
*/
35-
public function setUp()
36+
public function setUp(): void
3637
{
3738
$this->ioFileSystem = $this->getMockObject(IoFile::class);
3839
$this->tmpDirectory = $this->getMockObject(ReadFactory::class);
@@ -46,7 +47,7 @@ public function setUp()
4647
/**
4748
* @inheritdoc
4849
*/
49-
public function tearDown()
50+
public function tearDown(): void
5051
{
5152
unset($this->imageBackend);
5253
}
@@ -68,12 +69,12 @@ protected function getMockObject($class, $methods = [])
6869

6970
/**
7071
* Test for beforeSave method with invalid file extension.
71-
*
72-
* @expectedException \Magento\Framework\Exception\LocalizedException
73-
* @expectedExceptionMessage Invalid file provided.
7472
*/
7573
public function testBeforeSaveWithInvalidExtensionFile()
7674
{
75+
$this->expectException(LocalizedException::class);
76+
$this->expectExceptionMessage('Invalid file provided.');
77+
7778
$invalidFileName = 'fileName.invalidExtension';
7879
$this->imageBackend->setData(
7980
[

app/code/Magento/Theme/Test/Unit/Model/Wysiwyg/StorageTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
namespace Magento\Theme\Test\Unit\Model\Wysiwyg;
1111

12+
use Magento\Framework\Exception\LocalizedException;
1213
use Magento\Framework\Filesystem\DriverInterface;
1314

1415
/**
@@ -75,11 +76,9 @@ protected function setUp(): void
7576
$file->expects($this->any())
7677
->method('getPathInfo')
7778
->willReturnCallback(
78-
79-
function ($path) {
80-
return pathinfo($path);
81-
}
82-
79+
function ($path) {
80+
return pathinfo($path);
81+
}
8382
);
8483

8584
$this->_helperStorage = $this->createPartialMock(
@@ -200,7 +199,7 @@ public function testUploadFile()
200199
*/
201200
public function testUploadInvalidFile()
202201
{
203-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
202+
$this->expectException(LocalizedException::class);
204203

205204
$uploader = $this->_prepareUploader();
206205

@@ -302,7 +301,7 @@ public function testCreateFolder($isWritable)
302301
*/
303302
public function testCreateFolderWithInvalidName()
304303
{
305-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
304+
$this->expectException(LocalizedException::class);
306305

307306
$newDirectoryName = 'dir2!#$%^&';
308307
$this->_storageModel->createFolder($newDirectoryName, $this->_storageRoot);
@@ -313,7 +312,7 @@ public function testCreateFolderWithInvalidName()
313312
*/
314313
public function testCreateFolderDirectoryAlreadyExist()
315314
{
316-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
315+
$this->expectException(LocalizedException::class);
317316

318317
$newDirectoryName = 'mew';
319318
$fullNewPath = $this->_storageRoot . '/' . $newDirectoryName;
@@ -370,7 +369,7 @@ public function testGetDirsCollection()
370369
*/
371370
public function testGetDirsCollectionWrongDirName()
372371
{
373-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
372+
$this->expectException(LocalizedException::class);
374373

375374
$this->directoryWrite->expects(
376375
$this->once()
@@ -567,7 +566,7 @@ public function testDeleteDirectory()
567566
*/
568567
public function testDeleteRootDirectory()
569568
{
570-
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
569+
$this->expectException(LocalizedException::class);
571570

572571
$directoryPath = $this->_storageRoot;
573572

@@ -592,11 +591,12 @@ public function booleanCasesDataProvider()
592591

593592
/**
594593
* cover \Magento\Theme\Model\Wysiwyg\Storage::deleteDirectory
595-
* @expectedException \Magento\Framework\Exception\LocalizedException
596-
* @expectedExceptionMessage We can't delete root directory fake/relative/path right now.
597594
*/
598595
public function testDeleteRootDirectoryRelative()
599596
{
597+
$this->expectException(LocalizedException::class);
598+
$this->expectExceptionMessage('We can\'t delete root directory fake/relative/path right now.');
599+
600600
$directoryPath = $this->_storageRoot;
601601
$fakePath = 'fake/relative/path';
602602
$this->directoryWrite->method('getAbsolutePath')

0 commit comments

Comments
 (0)