Skip to content

Commit 12442e6

Browse files
authored
Merge pull request #1828 from yolouiese/1823-cover-getassetbyidinterface-with-integration-test
#1823: Cover GetAssetByIdInterface with integration test
2 parents c68f8a2 + 815f70b commit 12442e6

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\AdobeStockAsset\Test\Integration\Model;
9+
10+
use Magento\AdobeStockAssetApi\Api\GetAssetByIdInterface;
11+
use Magento\AdobeStockClientApi\Api\ClientInterface;
12+
use Magento\Framework\Api\Search\DocumentInterface;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
use PHPUnit\Framework\TestCase;
15+
16+
class GetAssetByIdTest extends TestCase
17+
{
18+
/**
19+
* @var GetAssetByIdInterface
20+
*/
21+
private $getAssetById;
22+
23+
protected function setUp(): void
24+
{
25+
Bootstrap::getObjectManager()->configure([
26+
'preferences' => [
27+
ClientInterface::class => ClientMock::class
28+
]
29+
]);
30+
31+
$this->getAssetById = Bootstrap::getObjectManager()->get(GetAssetByIdInterface::class);
32+
}
33+
34+
public function testExecute(): void
35+
{
36+
/** @var DocumentInterface $searchResults */
37+
$searchResults = $this->getAssetById->execute(1);
38+
39+
$this->assertInstanceOf(DocumentInterface::class, $searchResults);
40+
$this->assertNotEmpty($searchResults);
41+
$this->assertEquals(1, $searchResults->getId());
42+
}
43+
}

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)