Skip to content

Commit 815f70b

Browse files
committed
#1823: Cover GetAssetByIdInterface with integration test - replaced the mock class with existing mock class and modified the sample data for the existing mock class
1 parent a729054 commit 815f70b

File tree

4 files changed

+7
-87
lines changed

4 files changed

+7
-87
lines changed

AdobeStockAsset/Test/Integration/Model/ClientMock.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function search(SearchCriteriaInterface $searchCriteria): SearchResultInt
3535
$searchResult = new SearchResult();
3636
$searchResult->setSearchCriteria($searchCriteria);
3737
$searchResult->setItems($items);
38-
$searchResult->setTotalCount(3);
38+
$searchResult->setTotalCount(1);
3939

4040
return $searchResult;
4141
}
@@ -64,40 +64,6 @@ private function getStockFiles(): array
6464
],
6565
'category_id' => 1
6666
]
67-
],
68-
[
69-
'id' => 2,
70-
'custom_attributes' => [
71-
'id_field_name' => 'id',
72-
'id' => 2,
73-
'thumbnail_240_url' => 'https://test.url/2',
74-
'width' => 120,
75-
'height' => 220,
76-
'comp_url' => 'https://test.url/2',
77-
'category' => [
78-
'id' => 1,
79-
'name' => 'Test',
80-
'link' => null
81-
],
82-
'category_id' => 1
83-
]
84-
],
85-
[
86-
'id' => 3,
87-
'custom_attributes' => [
88-
'id_field_name' => 'id',
89-
'id' => 3,
90-
'thumbnail_240_url' => 'https://test.url/3',
91-
'width' => 130,
92-
'height' => 230,
93-
'comp_url' => 'https://test.url/3',
94-
'category' => [
95-
'id' => 1,
96-
'name' => 'Test',
97-
'link' => null
98-
],
99-
'category_id' => 1
100-
],
10167
]
10268
];
10369

AdobeStockAsset/Test/Integration/Model/GetAssetByIdTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace Magento\AdobeStockAsset\Test\Integration\Model;
99

1010
use Magento\AdobeStockAssetApi\Api\GetAssetByIdInterface;
11-
use Magento\AdobeStockAssetApi\Api\GetAssetListInterface;
11+
use Magento\AdobeStockClientApi\Api\ClientInterface;
1212
use Magento\Framework\Api\Search\DocumentInterface;
1313
use Magento\TestFramework\Helper\Bootstrap;
1414
use PHPUnit\Framework\TestCase;
@@ -24,7 +24,7 @@ protected function setUp(): void
2424
{
2525
Bootstrap::getObjectManager()->configure([
2626
'preferences' => [
27-
GetAssetListInterface::class => GetAssetListMock::class
27+
ClientInterface::class => ClientMock::class
2828
]
2929
]);
3030

@@ -34,10 +34,10 @@ protected function setUp(): void
3434
public function testExecute(): void
3535
{
3636
/** @var DocumentInterface $searchResults */
37-
$searchResults = $this->getAssetById->execute(123455678);
37+
$searchResults = $this->getAssetById->execute(1);
3838

3939
$this->assertInstanceOf(DocumentInterface::class, $searchResults);
4040
$this->assertNotEmpty($searchResults);
41-
$this->assertEquals(123455678, $searchResults->getId());
41+
$this->assertEquals(1, $searchResults->getId());
4242
}
4343
}

AdobeStockAsset/Test/Integration/Model/GetAssetListMock.php

Lines changed: 0 additions & 46 deletions
This file was deleted.

AdobeStockAsset/Test/Integration/Model/GetAssetListTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function testExecute(): void
6363
$searchResults = $this->getAssetList->execute($searchCriteria);
6464

6565
$this->assertInstanceOf(SearchResultInterface::class, $searchResults);
66-
$this->assertEquals(3, $searchResults->getTotalCount());
67-
$this->assertCount(3, array_values($searchResults->getItems()));
66+
$this->assertEquals(1, $searchResults->getTotalCount());
67+
$this->assertCount(1, array_values($searchResults->getItems()));
6868
}
6969
}

0 commit comments

Comments
 (0)