Skip to content

Commit e5431b4

Browse files
committed
AC-15047::[CE] PHPUnit 12: Upgrade Media & Asset Management related test cases
1 parent 835e075 commit e5431b4

File tree

33 files changed

+234
-251
lines changed

33 files changed

+234
-251
lines changed

app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/DeleteByDirectoryPathTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -49,7 +49,7 @@ class DeleteByDirectoryPathTest extends TestCase
4949
*/
5050
protected function setUp(): void
5151
{
52-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
52+
$this->logger = $this->createMock(LoggerInterface::class);
5353
$this->resourceConnection = $this->createMock(ResourceConnection::class);
5454

5555
$this->deleteMediaAssetByDirectoryPath = (new ObjectManager($this))->getObject(
@@ -60,7 +60,7 @@ protected function setUp(): void
6060
]
6161
);
6262

63-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
63+
$this->adapter = $this->createMock(AdapterInterface::class);
6464
}
6565

6666
/**

app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/DeleteByPathTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -44,7 +44,7 @@ class DeleteByPathTest extends TestCase
4444
*/
4545
protected function setUp(): void
4646
{
47-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
47+
$this->logger = $this->createMock(LoggerInterface::class);
4848
$resourceConnection = $this->createMock(ResourceConnection::class);
4949

5050
$this->deleteMediaAssetByPath = (new ObjectManager($this))->getObject(
@@ -55,7 +55,7 @@ protected function setUp(): void
5555
]
5656
);
5757

58-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
58+
$this->adapter = $this->createMock(AdapterInterface::class);
5959
$resourceConnection->expects($this->once())
6060
->method('getConnection')
6161
->willReturn($this->adapter);

app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionDuringMediaAssetInitializationTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -70,8 +70,8 @@ class GetByIdExceptionDuringMediaAssetInitializationTest extends TestCase
7070
protected function setUp(): void
7171
{
7272
$resourceConnection = $this->createMock(ResourceConnection::class);
73-
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class);
74-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
73+
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class); // @phpstan-ignore-line
74+
$this->logger = $this->createMock(LoggerInterface::class);
7575

7676
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
7777
GetById::class,
@@ -81,7 +81,7 @@ protected function setUp(): void
8181
'logger' => $this->logger,
8282
]
8383
);
84-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
84+
$this->adapter = $this->createMock(AdapterInterface::class);
8585
$resourceConnection->method('getConnection')->willReturn($this->adapter);
8686

8787
$this->selectStub = $this->createMock(Select::class);

app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionNoSuchEntityTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -57,8 +57,8 @@ class GetByIdExceptionNoSuchEntityTest extends TestCase
5757
protected function setUp(): void
5858
{
5959
$resourceConnection = $this->createMock(ResourceConnection::class);
60-
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class);
61-
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
60+
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class); // @phpstan-ignore-line
61+
$logger = $this->createMock(LoggerInterface::class);
6262

6363
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
6464
GetById::class,
@@ -68,15 +68,15 @@ protected function setUp(): void
6868
'logger' => $logger,
6969
]
7070
);
71-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
71+
$this->adapter = $this->createMock(AdapterInterface::class);
7272
$resourceConnection->method('getConnection')->willReturn($this->adapter);
7373

7474
$this->selectStub = $this->createMock(Select::class);
7575
$this->selectStub->method('from')->willReturnSelf();
7676
$this->selectStub->method('where')->willReturnSelf();
7777
$this->adapter->method('select')->willReturn($this->selectStub);
7878

79-
$this->statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
79+
$this->statementMock = $this->createMock(\Zend_Db_Statement_Interface::class);
8080
}
8181

8282
/**

app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdExceptionOnGetDataTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -70,8 +70,8 @@ class GetByIdExceptionOnGetDataTest extends TestCase
7070
protected function setUp(): void
7171
{
7272
$resourceConnection = $this->createMock(ResourceConnection::class);
73-
$assetFactory = $this->createMock(AssetInterfaceFactory::class);
74-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
73+
$assetFactory = $this->createMock(AssetInterfaceFactory::class); // @phpstan-ignore-line
74+
$this->logger = $this->createMock(LoggerInterface::class);
7575

7676
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
7777
GetById::class,
@@ -81,15 +81,15 @@ protected function setUp(): void
8181
'logger' => $this->logger,
8282
]
8383
);
84-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
84+
$this->adapter = $this->createMock(AdapterInterface::class);
8585
$resourceConnection->method('getConnection')->willReturn($this->adapter);
8686

8787
$this->selectStub = $this->createMock(Select::class);
8888
$this->selectStub->method('from')->willReturnSelf();
8989
$this->selectStub->method('where')->willReturnSelf();
9090
$this->adapter->method('select')->willReturn($this->selectStub);
9191

92-
$this->statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
92+
$this->statementMock = $this->createMock(\Zend_Db_Statement_Interface::class);
9393
}
9494

9595
/**

app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/GetByIdSuccessfulTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -71,8 +71,8 @@ class GetByIdSuccessfulTest extends TestCase
7171
protected function setUp(): void
7272
{
7373
$resourceConnection = $this->createMock(ResourceConnection::class);
74-
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class);
75-
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
74+
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class); // @phpstan-ignore-line
75+
$logger = $this->createMock(LoggerInterface::class);
7676

7777
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
7878
GetById::class,
@@ -82,15 +82,15 @@ protected function setUp(): void
8282
'logger' => $logger,
8383
]
8484
);
85-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
85+
$this->adapter = $this->createMock(AdapterInterface::class);
8686
$resourceConnection->method('getConnection')->willReturn($this->adapter);
8787

8888
$this->selectStub = $this->createMock(Select::class);
8989
$this->selectStub->method('from')->willReturnSelf();
9090
$this->selectStub->method('where')->willReturnSelf();
9191
$this->adapter->method('select')->willReturn($this->selectStub);
9292

93-
$this->statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
93+
$this->statementMock = $this->createMock(\Zend_Db_Statement_Interface::class);
9494
}
9595

9696
/**
@@ -101,8 +101,7 @@ public function testSuccessfulGetByIdExecution(): void
101101
$this->statementMock->method('fetch')->willReturn(self::MEDIA_ASSET_DATA);
102102
$this->adapter->method('query')->willReturn($this->statementMock);
103103

104-
$mediaAssetStub = $this->getMockBuilder(AssetInterface::class)
105-
->getMock();
104+
$mediaAssetStub = $this->createMock(AssetInterface::class);
106105
$this->assetFactory->expects($this->once())->method('create')->willReturn($mediaAssetStub);
107106

108107
$this->assertEquals(

app/code/Magento/MediaGallery/Test/Unit/Model/Asset/Command/SaveTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -95,11 +95,11 @@ protected function setUp(): void
9595
{
9696
/* Intermediary mocks */
9797
$this->adapterMock = $this->createMock(Mysql::class);
98-
$this->mediaAssetMock = $this->getMockForAbstractClass(AssetInterface::class);
98+
$this->mediaAssetMock = $this->createMock(AssetInterface::class);
9999

100100
/* Save constructor mocks */
101101
$this->objectProcessor = $this->createMock(DataObjectProcessor::class);
102-
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
102+
$this->loggerMock = $this->createMock(LoggerInterface::class);
103103
$this->resourceConnectionMock = $this->createConfiguredMock(
104104
ResourceConnection::class,
105105
[

app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/GetAssetKeywordsTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -43,8 +43,8 @@ class GetAssetKeywordsTest extends TestCase
4343
protected function setUp(): void
4444
{
4545
$this->resourceConnectionStub = $this->createMock(ResourceConnection::class);
46-
$this->assetKeywordFactoryStub = $this->createMock(KeywordInterfaceFactory::class);
47-
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
46+
$this->assetKeywordFactoryStub = $this->createMock(KeywordInterfaceFactory::class); // @phpstan-ignore-line
47+
$this->loggerMock = $this->createMock(LoggerInterface::class);
4848

4949
$this->sut = new GetAssetKeywords(
5050
$this->resourceConnectionStub,
@@ -123,7 +123,7 @@ public function testNotFoundBecauseOfError(): void
123123
*/
124124
private function configureResourceConnectionStub(array $queryResult): void
125125
{
126-
$statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
126+
$statementMock = $this->createMock(\Zend_Db_Statement_Interface::class);
127127
$statementMock
128128
->method('fetchAll')
129129
->willReturn($queryResult);
@@ -133,8 +133,7 @@ private function configureResourceConnectionStub(array $queryResult): void
133133
$selectStub->method('join')->willReturnSelf();
134134
$selectStub->method('where')->willReturnSelf();
135135

136-
$connectionMock = $this->getMockBuilder(AdapterInterface::class)
137-
->getMock();
136+
$connectionMock = $this->createMock(AdapterInterface::class);
138137
$connectionMock
139138
->method('select')
140139
->willReturn($selectStub);
@@ -149,8 +148,7 @@ private function configureResourceConnectionStub(array $queryResult): void
149148

150149
private function configureAssetKeywordFactoryStub(): void
151150
{
152-
$keywordStub = $this->getMockBuilder(KeywordInterface::class)
153-
->getMock();
151+
$keywordStub = $this->createMock(KeywordInterface::class);
154152
$this->assetKeywordFactoryStub
155153
->method('create')
156154
->willReturn($keywordStub);

app/code/Magento/MediaGallery/Test/Unit/Model/Keyword/Command/SaveAssetKeywordsTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2018 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -57,11 +57,9 @@ protected function setUp(): void
5757
{
5858
$this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
5959
$this->saveAssetLinksMock = $this->createMock(SaveAssetLinks::class);
60-
$this->connectionMock = $this->getMockBuilder(Mysql::class)
61-
->disableOriginalConstructor()
62-
->getMock();
60+
$this->connectionMock = $this->createMock(Mysql::class);
6361
$this->selectMock = $this->createMock(Select::class);
64-
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
62+
$this->loggerMock = $this->createMock(LoggerInterface::class);
6563

6664
$this->sut = new SaveAssetKeywords(
6765
$this->resourceConnectionMock,

app/code/Magento/MediaGallery/Test/Unit/Model/ResourceModel/DeleteAssetsByPathsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ public function testDeleteCorrectAssetByPathWithCaseSensitiveMatches(
7070

7171
protected function setUp(): void
7272
{
73-
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
73+
$logger = $this->createMock(LoggerInterface::class);
7474
$resourceConnection = $this->createMock(ResourceConnection::class);
7575

7676
$this->deleteAssetsByPaths = new DeleteAssetsByPaths(
7777
$resourceConnection,
7878
$logger
7979
);
8080

81-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
81+
$this->adapter = $this->createMock(AdapterInterface::class);
8282
$this->select = $this->createMock(Select::class);
8383
$this->statement = $this->createMock(\Zend_Db_Statement_Interface::class);
8484

0 commit comments

Comments
 (0)