Skip to content

Commit 53c102e

Browse files
Merge branch 'MC-41153' into 2.3.7-develop-2.3-develop-sync-030921
# Conflicts: # dev/tests/functional/tests/app/Magento/CatalogUrlRewrite/Test/TestCase/CreateDuplicateUrlProductEntity.php # dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/CreateExistingCustomerFrontendEntity.php
2 parents c16d82e + ec32847 commit 53c102e

File tree

13 files changed

+79
-40
lines changed

13 files changed

+79
-40
lines changed

app/code/Magento/Captcha/Test/Unit/Model/Filter/QuoteDataConfigFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class QuoteDataConfigFilterTest extends TestCase
3030
/**
3131
* Initialize Class Dependencies
3232
*/
33-
protected function setUp()
33+
protected function setUp(): void
3434
{
3535
$this->objectManager = new ObjectManager($this);
3636

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

Lines changed: 13 additions & 7 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);
@@ -539,10 +541,14 @@ public function testUploadFile()
539541
}
540542

541543
/**
542-
* @expectedException \Magento\Framework\Exception\LocalizedException
544+
*
543545
*/
544546
public function testUploadFileWithExcessivePath()
545547
{
548+
$this->expectException(
549+
\Magento\Framework\Exception\LocalizedException::class
550+
);
551+
546552
$path = 'target/path';
547553
$targetPath = self::STORAGE_ROOT_DIR .str_repeat('a', 255) . $path;
548554
$type = 'image';

app/code/Magento/Customer/Test/Unit/Model/Address/Validator/CustomerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class CustomerTest extends TestCase
2929
/**
3030
* @inheritDoc
3131
*/
32-
protected function setUp()
32+
protected function setUp(): void
3333
{
3434
$this->addressFactoryMock = $this->createMock(AddressFactory::class);
3535
$objectManager = new ObjectManager($this);

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/Customer/Test/Unit/Model/Metadata/Form/ImageTest.php

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,27 @@ class ImageTest extends AbstractFormTestCase
7676
private $fileProcessorFactoryMock;
7777

7878
/**
79-
* @var File|PHPUnit_Framework_MockObject_MockObject
79+
* @var File|\PHPUnit\Framework\MockObject\MockObject
8080
*/
8181
private $ioFileSystemMock;
8282

8383
/**
84-
* @var DirectoryList|PHPUnit_Framework_MockObject_MockObject
84+
* @var DirectoryList|\PHPUnit\Framework\MockObject\MockObject
8585
*/
8686
private $directoryListMock;
8787

8888
/**
89-
* @var WriteFactory|PHPUnit_Framework_MockObject_MockObject
89+
* @var WriteFactory|\PHPUnit\Framework\MockObject\MockObject
9090
*/
9191
private $writeFactoryMock;
9292

9393
/**
94-
* @var Write|PHPUnit_Framework_MockObject_MockObject
94+
* @var Write|\PHPUnit\Framework\MockObject\MockObject
9595
*/
9696
private $mediaEntityTmpDirectoryMock;
9797

9898
/**
99-
* @var Driver|PHPUnit_Framework_MockObject_MockObject
99+
* @var Driver|\PHPUnit\Framework\MockObject\MockObject
100100
*/
101101
private $driverMock;
102102

@@ -251,6 +251,14 @@ public function testValidate()
251251
->with(FileProcessor::TMP_DIR . '/' . $value['name'])
252252
->willReturn(true);
253253

254+
$this->ioFileSystemMock->expects($this->any())
255+
->method('getPathInfo')
256+
->with($value['name'])
257+
->willReturn([
258+
'extension' => 'gif',
259+
'filename' => 'logo'
260+
]);
261+
254262
$model = $this->initialize([
255263
'value' => $value,
256264
'isAjax' => false,
@@ -304,6 +312,14 @@ public function testValidateMaxFileSize()
304312
->with(FileProcessor::TMP_DIR . '/' . $value['name'])
305313
->willReturn(true);
306314

315+
$this->ioFileSystemMock->expects($this->any())
316+
->method('getPathInfo')
317+
->with($value['name'])
318+
->willReturn([
319+
'extension' => 'gif',
320+
'filename' => 'logo'
321+
]);
322+
307323
$model = $this->initialize([
308324
'value' => $value,
309325
'isAjax' => false,
@@ -356,6 +372,14 @@ public function testValidateMaxImageWidth()
356372
->with(FileProcessor::TMP_DIR . '/' . $value['name'])
357373
->willReturn(true);
358374

375+
$this->ioFileSystemMock->expects($this->any())
376+
->method('getPathInfo')
377+
->with($value['name'])
378+
->willReturn([
379+
'extension' => 'gif',
380+
'filename' => 'logo'
381+
]);
382+
359383
$model = $this->initialize([
360384
'value' => $value,
361385
'isAjax' => false,
@@ -408,6 +432,14 @@ public function testValidateMaxImageHeight()
408432
->with(FileProcessor::TMP_DIR . '/' . $value['name'])
409433
->willReturn(true);
410434

435+
$this->ioFileSystemMock->expects($this->any())
436+
->method('getPathInfo')
437+
->with($value['name'])
438+
->willReturn([
439+
'extension' => 'gif',
440+
'filename' => 'logo'
441+
]);
442+
411443
$model = $this->initialize([
412444
'value' => $value,
413445
'isAjax' => false,

app/code/Magento/Customer/Test/Unit/Model/Webapi/ParamOverriderCustomerGroupIdTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ParamOverriderCustomerGroupIdTest extends TestCase
3838
/**
3939
* @inheritDoc
4040
*/
41-
protected function setUp()
41+
protected function setUp(): void
4242
{
4343
$this->userContextMock = $this->createMock(UserContextInterface::class);
4444
$this->customerRepositoryMock = $this->createMock(CustomerRepositoryInterface::class);

app/code/Magento/Customer/Test/Unit/Model/Webapi/ParamOverriderCustomerStoreIdTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ParamOverriderCustomerStoreIdTest extends TestCase
3838
/**
3939
* @inheritDoc
4040
*/
41-
protected function setUp()
41+
protected function setUp(): void
4242
{
4343
$this->userContextMock = $this->createMock(UserContextInterface::class);
4444
$this->customerRepositoryMock = $this->createMock(CustomerRepositoryInterface::class);

app/code/Magento/Customer/Test/Unit/Model/Webapi/ParamOverriderCustomerWebsiteIdTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ParamOverriderCustomerWebsiteIdTest extends TestCase
3838
/**
3939
* @inheritDoc
4040
*/
41-
protected function setUp()
41+
protected function setUp(): void
4242
{
4343
$this->userContextMock = $this->createMock(UserContextInterface::class);
4444
$this->customerRepositoryMock = $this->createMock(CustomerRepositoryInterface::class);

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)