Skip to content

Commit dd2a8cd

Browse files
Merge remote-tracking branch 'origin/Arrows-AC-15047' into AC-15049-Security_Authentication
2 parents 7dd2735 + 1356e17 commit dd2a8cd

File tree

28 files changed

+221
-220
lines changed

28 files changed

+221
-220
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\Exception\CouldNotDeleteException;
1313
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1414
use Magento\MediaGallery\Model\Asset\Command\DeleteByDirectoryPath;
15+
use PHPUnit\Framework\Attributes\DataProvider;
1516
use PHPUnit\Framework\MockObject\MockObject;
1617
use PHPUnit\Framework\TestCase;
1718
use Psr\Log\LoggerInterface;
@@ -49,7 +50,7 @@ class DeleteByDirectoryPathTest extends TestCase
4950
*/
5051
protected function setUp(): void
5152
{
52-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
53+
$this->logger = $this->createMock(LoggerInterface::class);
5354
$this->resourceConnection = $this->createMock(ResourceConnection::class);
5455

5556
$this->deleteMediaAssetByDirectoryPath = (new ObjectManager($this))->getObject(
@@ -60,16 +61,16 @@ protected function setUp(): void
6061
]
6162
);
6263

63-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
64+
$this->adapter = $this->createMock(AdapterInterface::class);
6465
}
6566

6667
/**
6768
* Test delete media asset by path command
6869
*
6970
* @param string $directoryPath
7071
* @throws CouldNotDeleteException
71-
* @dataProvider directoryPathDataProvider
7272
*/
73+
#[DataProvider('directoryPathDataProvider')]
7374
public function testDeleteByDirectoryPath(string $directoryPath): void
7475
{
7576
if (!empty($directoryPath)) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ protected function setUp(): void
7171
{
7272
$resourceConnection = $this->createMock(ResourceConnection::class);
7373
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class);
74-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
2020
use Psr\Log\LoggerInterface;
21+
use Zend_Db_Statement_Interface;
2122

2223
/**
2324
* Test the GetById command with exception thrown in case when there is no such entity
@@ -58,7 +59,7 @@ protected function setUp(): void
5859
{
5960
$resourceConnection = $this->createMock(ResourceConnection::class);
6061
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class);
61-
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
62+
$logger = $this->createMock(LoggerInterface::class);
6263

6364
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
6465
GetById::class,
@@ -68,15 +69,15 @@ protected function setUp(): void
6869
'logger' => $logger,
6970
]
7071
);
71-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
72+
$this->adapter = $this->createMock(AdapterInterface::class);
7273
$resourceConnection->method('getConnection')->willReturn($this->adapter);
7374

7475
$this->selectStub = $this->createMock(Select::class);
7576
$this->selectStub->method('from')->willReturnSelf();
7677
$this->selectStub->method('where')->willReturnSelf();
7778
$this->adapter->method('select')->willReturn($this->selectStub);
7879

79-
$this->statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
80+
$this->statementMock = $this->createMock(Zend_Db_Statement_Interface::class);
8081
}
8182

8283
/**

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
2020
use Psr\Log\LoggerInterface;
21+
use Zend_Db_Statement_Interface;
2122

2223
/**
2324
* Test the GetById command with exception during get media data
@@ -71,7 +72,7 @@ protected function setUp(): void
7172
{
7273
$resourceConnection = $this->createMock(ResourceConnection::class);
7374
$assetFactory = $this->createMock(AssetInterfaceFactory::class);
74-
$this->logger = $this->getMockForAbstractClass(LoggerInterface::class);
75+
$this->logger = $this->createMock(LoggerInterface::class);
7576

7677
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
7778
GetById::class,
@@ -81,15 +82,15 @@ protected function setUp(): void
8182
'logger' => $this->logger,
8283
]
8384
);
84-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
85+
$this->adapter = $this->createMock(AdapterInterface::class);
8586
$resourceConnection->method('getConnection')->willReturn($this->adapter);
8687

8788
$this->selectStub = $this->createMock(Select::class);
8889
$this->selectStub->method('from')->willReturnSelf();
8990
$this->selectStub->method('where')->willReturnSelf();
9091
$this->adapter->method('select')->willReturn($this->selectStub);
9192

92-
$this->statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
93+
$this->statementMock = $this->createMock(Zend_Db_Statement_Interface::class);
9394
}
9495

9596
/**

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
2020
use Psr\Log\LoggerInterface;
21+
use Zend_Db_Statement_Interface;
2122

2223
/**
2324
* Test the GetById command successful scenario
@@ -72,7 +73,7 @@ protected function setUp(): void
7273
{
7374
$resourceConnection = $this->createMock(ResourceConnection::class);
7475
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class);
75-
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
76+
$logger = $this->createMock(LoggerInterface::class);
7677

7778
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
7879
GetById::class,
@@ -82,15 +83,15 @@ protected function setUp(): void
8283
'logger' => $logger,
8384
]
8485
);
85-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
86+
$this->adapter = $this->createMock(AdapterInterface::class);
8687
$resourceConnection->method('getConnection')->willReturn($this->adapter);
8788

8889
$this->selectStub = $this->createMock(Select::class);
8990
$this->selectStub->method('from')->willReturnSelf();
9091
$this->selectStub->method('where')->willReturnSelf();
9192
$this->adapter->method('select')->willReturn($this->selectStub);
9293

93-
$this->statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
94+
$this->statementMock = $this->createMock(Zend_Db_Statement_Interface::class);
9495
}
9596

9697
/**
@@ -101,8 +102,7 @@ public function testSuccessfulGetByIdExecution(): void
101102
$this->statementMock->method('fetch')->willReturn(self::MEDIA_ASSET_DATA);
102103
$this->adapter->method('query')->willReturn($this->statementMock);
103104

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

108108
$this->assertEquals(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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 & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
use Magento\MediaGallery\Model\Keyword\Command\GetAssetKeywords;
1515
use Magento\MediaGalleryApi\Api\Data\KeywordInterface;
1616
use Magento\MediaGalleryApi\Api\Data\KeywordInterfaceFactory;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1718
use PHPUnit\Framework\MockObject\MockObject;
1819
use PHPUnit\Framework\TestCase;
1920
use Psr\Log\LoggerInterface;
21+
use Zend_Db_Statement_Interface;
2022

2123
class GetAssetKeywordsTest extends TestCase
2224
{
@@ -44,7 +46,7 @@ protected function setUp(): void
4446
{
4547
$this->resourceConnectionStub = $this->createMock(ResourceConnection::class);
4648
$this->assetKeywordFactoryStub = $this->createMock(KeywordInterfaceFactory::class);
47-
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
49+
$this->loggerMock = $this->createMock(LoggerInterface::class);
4850

4951
$this->sut = new GetAssetKeywords(
5052
$this->resourceConnectionStub,
@@ -56,10 +58,10 @@ protected function setUp(): void
5658
/**
5759
* Posive test for the main case
5860
*
59-
* @dataProvider casesProvider
6061
* @param array $databaseQueryResult
6162
* @param int $expectedNumberOfFoundKeywords
6263
*/
64+
#[DataProvider('casesProvider')]
6365
public function testFind(array $databaseQueryResult, int $expectedNumberOfFoundKeywords): void
6466
{
6567
$randomAssetId = 12345;
@@ -123,7 +125,7 @@ public function testNotFoundBecauseOfError(): void
123125
*/
124126
private function configureResourceConnectionStub(array $queryResult): void
125127
{
126-
$statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)->getMock();
128+
$statementMock = $this->createMock(Zend_Db_Statement_Interface::class);
127129
$statementMock
128130
->method('fetchAll')
129131
->willReturn($queryResult);
@@ -133,8 +135,7 @@ private function configureResourceConnectionStub(array $queryResult): void
133135
$selectStub->method('join')->willReturnSelf();
134136
$selectStub->method('where')->willReturnSelf();
135137

136-
$connectionMock = $this->getMockBuilder(AdapterInterface::class)
137-
->getMock();
138+
$connectionMock = $this->createMock(AdapterInterface::class);
138139
$connectionMock
139140
->method('select')
140141
->willReturn($selectStub);
@@ -149,8 +150,7 @@ private function configureResourceConnectionStub(array $queryResult): void
149150

150151
private function configureAssetKeywordFactoryStub(): void
151152
{
152-
$keywordStub = $this->getMockBuilder(KeywordInterface::class)
153-
->getMock();
153+
$keywordStub = $this->createMock(KeywordInterface::class);
154154
$this->assetKeywordFactoryStub
155155
->method('create')
156156
->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
@@ -14,6 +14,7 @@
1414
use Magento\Framework\Exception\CouldNotSaveException;
1515
use Magento\MediaGallery\Model\Keyword\Command\SaveAssetKeywords;
1616
use Magento\MediaGallery\Model\ResourceModel\Keyword\SaveAssetLinks;
17+
use PHPUnit\Framework\Attributes\DataProvider;
1718
use PHPUnit\Framework\MockObject\MockObject;
1819
use PHPUnit\Framework\TestCase;
1920
use Psr\Log\LoggerInterface;
@@ -57,11 +58,9 @@ protected function setUp(): void
5758
{
5859
$this->resourceConnectionMock = $this->createMock(ResourceConnection::class);
5960
$this->saveAssetLinksMock = $this->createMock(SaveAssetLinks::class);
60-
$this->connectionMock = $this->getMockBuilder(Mysql::class)
61-
->disableOriginalConstructor()
62-
->getMock();
61+
$this->connectionMock = $this->createMock(Mysql::class);
6362
$this->selectMock = $this->createMock(Select::class);
64-
$this->loggerMock = $this->getMockForAbstractClass(LoggerInterface::class);
63+
$this->loggerMock = $this->createMock(LoggerInterface::class);
6564

6665
$this->sut = new SaveAssetKeywords(
6766
$this->resourceConnectionMock,
@@ -73,12 +72,11 @@ protected function setUp(): void
7372
/**
7473
* Test saving the asset keywords
7574
*
76-
* @dataProvider assetKeywordsDataProvider
77-
*
7875
* @param array $keywords
7976
* @param int $assetId
8077
* @param array $items
8178
*/
79+
#[DataProvider('assetKeywordsDataProvider')]
8280
public function testAssetKeywordsSave(array $keywords, int $assetId, array $items): void
8381
{
8482
$expectedCalls = (int) (count($keywords));

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\DB\Select;
1313
use Magento\Framework\Exception\CouldNotDeleteException;
1414
use Magento\MediaGallery\Model\ResourceModel\DeleteAssetsByPaths;
15+
use PHPUnit\Framework\Attributes\DataProvider;
1516
use PHPUnit\Framework\MockObject\MockObject;
1617
use PHPUnit\Framework\TestCase;
1718
use Psr\Log\LoggerInterface;
@@ -43,9 +44,9 @@ class DeleteAssetsByPathsTest extends TestCase
4344
/**
4445
* When deleting an asset by path with mixed case, the asset with exact same path should be deleted
4546
*
46-
* @dataProvider assetDeleteByPathDataProvider
4747
* @throws CouldNotDeleteException
4848
*/
49+
#[DataProvider('assetDeleteByPathDataProvider')]
4950
public function testDeleteCorrectAssetByPathWithCaseSensitiveMatches(
5051
array $assets,
5152
string $assetPathToDelete,
@@ -70,15 +71,15 @@ public function testDeleteCorrectAssetByPathWithCaseSensitiveMatches(
7071

7172
protected function setUp(): void
7273
{
73-
$logger = $this->getMockForAbstractClass(LoggerInterface::class);
74+
$logger = $this->createMock(LoggerInterface::class);
7475
$resourceConnection = $this->createMock(ResourceConnection::class);
7576

7677
$this->deleteAssetsByPaths = new DeleteAssetsByPaths(
7778
$resourceConnection,
7879
$logger
7980
);
8081

81-
$this->adapter = $this->getMockForAbstractClass(AdapterInterface::class);
82+
$this->adapter = $this->createMock(AdapterInterface::class);
8283
$this->select = $this->createMock(Select::class);
8384
$this->statement = $this->createMock(\Zend_Db_Statement_Interface::class);
8485

0 commit comments

Comments
 (0)