Skip to content

Commit 061d5a3

Browse files
committed
Change the way the setup method is called for GetById command test
1 parent b0fb363 commit 061d5a3

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Zend\Db\Adapter\Driver\Pdo\Statement;
2020

2121
/**
22-
* Test the GetById command model with exception during media asset initialization
22+
* Test the GetById command with exception during media asset initialization
2323
*/
2424
class GetByIdExceptionDuringMediaAssetInitializationTest extends \PHPUnit\Framework\TestCase
2525
{

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,21 @@ class GetByIdExceptionNoSuchEntityTest extends \PHPUnit\Framework\TestCase
5252
*/
5353
private $statementMock;
5454

55-
/**
56-
* @var LoggerInterface|MockObject
57-
*/
58-
private $logger;
59-
6055
/**
6156
* Initialize basic test class mocks
6257
*/
6358
protected function setUp(): void
6459
{
6560
$resourceConnection = $this->createMock(ResourceConnection::class);
6661
$this->assetFactory = $this->createMock(AssetInterfaceFactory::class);
67-
$this->logger = $this->createMock(LoggerInterface::class);
62+
$logger = $this->createMock(LoggerInterface::class);
6863

6964
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
7065
GetById::class,
7166
[
7267
'resourceConnection' => $resourceConnection,
7368
'assetFactory' => $this->assetFactory,
74-
'logger' => $this->logger,
69+
'logger' => $logger,
7570
]
7671
);
7772
$this->adapter = $this->createMock(AdapterInterface::class);

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class GetByIdExceptionOnGetDataTest extends \PHPUnit\Framework\TestCase
4141
*/
4242
private $selectStub;
4343

44+
/**
45+
* @var LoggerInterface|MockObject
46+
*/
47+
private $logger;
48+
4449
/**
4550
* @var Statement|MockObject
4651
*/
@@ -53,14 +58,14 @@ protected function setUp(): void
5358
{
5459
$resourceConnection = $this->createMock(ResourceConnection::class);
5560
$assetFactory = $this->createMock(AssetInterfaceFactory::class);
56-
$logger = $this->createMock(LoggerInterface::class);
61+
$this->logger = $this->createMock(LoggerInterface::class);
5762

5863
$this->getMediaAssetById = (new ObjectManager($this))->getObject(
5964
GetById::class,
6065
[
6166
'resourceConnection' => $resourceConnection,
6267
'assetFactory' => $assetFactory,
63-
'logger' => $logger,
68+
'logger' => $this->logger,
6469
]
6570
);
6671
$this->adapter = $this->createMock(AdapterInterface::class);
@@ -83,6 +88,9 @@ public function testExceptionDuringGetMediaAssetData(): void
8388
$this->adapter->method('query')->willThrowException(new \Exception());
8489

8590
$this->expectException(IntegrationException::class);
91+
$this->logger->expects($this->any())
92+
->method('critical')
93+
->willReturnSelf();
8694

8795
$this->getMediaAssetById->execute(self::MEDIA_ASSET_STUB_ID);
8896
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
use Zend\Db\Adapter\Driver\Pdo\Statement;
2020

2121
/**
22-
* Test the GetById command model
22+
* Test the GetById command successful scenario
2323
*/
24-
class GetByIdTest extends \PHPUnit\Framework\TestCase
24+
class GetByIdSuccessfulTest extends \PHPUnit\Framework\TestCase
2525
{
2626
private const MEDIA_ASSET_STUB_ID = 1;
2727

0 commit comments

Comments
 (0)