Skip to content

Commit 4d33b02

Browse files
committed
Fix integration and static tests
1 parent 73fb878 commit 4d33b02

11 files changed

+72
-57
lines changed

app/code/Magento/MediaContent/Model/ContentAssetLink.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
*/
1717
class ContentAssetLink implements ContentAssetLinkInterface
1818
{
19-
private const ASSET_ID = 'asset_id';
20-
private const CONTENT_IDENTITY = 'content_identity';
21-
2219
/**
2320
* @var ContentAssetLinkExtensionInterface|null
2421
*/
@@ -35,14 +32,16 @@ class ContentAssetLink implements ContentAssetLinkInterface
3532
private $assetId;
3633

3734
/**
35+
* ContentAssetLink constructor.
36+
* @param int $assetId
37+
* @param ContentIdentityInterface $contentIdentity
3838
* @param ContentAssetLinkExtensionInterface|null $extensionAttributes
3939
*/
4040
public function __construct(
4141
int $assetId,
4242
ContentIdentityInterface $contentIdentity,
4343
?ContentAssetLinkExtensionInterface $extensionAttributes = null
44-
)
45-
{
44+
) {
4645
$this->assetId = $assetId;
4746
$this->contentIdentity = $contentIdentity;
4847
$this->extensionAttributes = $extensionAttributes;
@@ -71,4 +70,12 @@ public function getExtensionAttributes(): ?ContentAssetLinkExtensionInterface
7170
{
7271
return $this->extensionAttributes;
7372
}
73+
74+
/**
75+
* @inheritdoc
76+
*/
77+
public function setExtensionAttributes(?ContentAssetLinkExtensionInterface $extensionAttributes): void
78+
{
79+
$this->extensionAttributes = $extensionAttributes;
80+
}
7481
}

app/code/Magento/MediaContent/Model/ContentIdentity.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,16 @@ public function getField(): string
6666
/**
6767
* @inheritdoc
6868
*/
69-
public function getExtensionAttributes(): ContentIdentityExtensionInterface
69+
public function getExtensionAttributes(): ?ContentIdentityExtensionInterface
7070
{
7171
return $this->extensionAttributes;
7272
}
73+
74+
/**
75+
* @inheritdoc
76+
*/
77+
public function setExtensionAttributes(?ContentIdentityExtensionInterface $extensionAttributes): void
78+
{
79+
$this->extensionAttributes = $extensionAttributes;
80+
}
7381
}

app/code/Magento/MediaContent/Model/DeleteContentAssetLinks.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public function execute(array $contentAssetLinks): void
6666
}
6767

6868
/**
69+
* Build sql where condition
70+
*
6971
* @param ContentAssetLinkInterface[] $contentAssetLinks
7072
* @return string
7173
*/
@@ -76,13 +78,16 @@ private function buildWhereSqlPart(array $contentAssetLinks): string
7678
foreach ($contentAssetLinks as $contentAssetLink) {
7779
$assetId = $connection->quoteInto(self::ASSET_ID . ' = ?', $contentAssetLink->getAssetId());
7880
$entityId = $connection->quoteInto(
79-
self::ENTITY_ID . ' = ?', $contentAssetLink->getContentId()->getEntityId()
81+
self::ENTITY_ID . ' = ?',
82+
$contentAssetLink->getContentId()->getEntityId()
8083
);
8184
$entityType = $connection->quoteInto(
82-
self::ENTITY_TYPE . ' = ?', $contentAssetLink->getContentId()->getEntityType()
85+
self::ENTITY_TYPE . ' = ?',
86+
$contentAssetLink->getContentId()->getEntityType()
8387
);
8488
$field = $connection->quoteInto(
85-
self::FIELD . ' = ?', $contentAssetLink->getContentId()->getField()
89+
self::FIELD . ' = ?',
90+
$contentAssetLink->getContentId()->getField()
8691
);
8792
$condition[] = '(' . $assetId . ' AND ' . $entityId . ' AND ' . $entityType . ' AND ' . $field . ')';
8893
}

app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByDirectoryPath.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public function __construct(
5252
}
5353

5454
/**
55+
* Around plugin on execute method
56+
*
5557
* @param DeleteByDirectoryPathInterface $subject
5658
* @param \Closure $proceed
5759
* @param string $directoryPath

app/code/Magento/MediaContent/Plugin/MediaGalleryAssetDeleteByPath.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public function __construct(
4949
}
5050

5151
/**
52+
* Around plugin on execute method
53+
*
5254
* @param DeleteByPathInterface $subject
5355
* @param \Closure $proceed
5456
* @param string $mediaAssetPath

app/code/Magento/MediaContentApi/Api/Data/ContentAssetLinkInterface.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,12 @@ public function getAssetId(): int;
3737
* @return \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface|null
3838
*/
3939
public function getExtensionAttributes(): ?ContentAssetLinkExtensionInterface;
40+
41+
/**
42+
* Set extension attributes
43+
*
44+
* @param \Magento\MediaContentApi\Api\Data\ContentAssetLinkExtensionInterface|null $extensionAttributes
45+
* @return void
46+
*/
47+
public function setExtensionAttributes(?ContentAssetLinkExtensionInterface $extensionAttributes): void;
4048
}

app/code/Magento/MediaContentApi/Api/Data/ContentIdentityInterface.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,13 @@ public function getField(): string;
4343
*
4444
* @return \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface|null
4545
*/
46-
public function getExtensionAttributes(): ContentIdentityExtensionInterface;
46+
public function getExtensionAttributes(): ?ContentIdentityExtensionInterface;
47+
48+
/**
49+
* Set extension attributes
50+
*
51+
* @param \Magento\MediaContentApi\Api\Data\ContentIdentityExtensionInterface|null $extensionAttributes
52+
* @return void
53+
*/
54+
public function setExtensionAttributes(?ContentIdentityExtensionInterface $extensionAttributes): void;
4755
}

app/code/Magento/MediaContentApi/Api/ExtractAssetsFromContentEntitiesInterface.php

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

dev/tests/integration/testsuite/Magento/MediaContent/Model/ExtractAssetsFromContentTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@ class ExtractAssetsFromContentTest extends TestCase
2020
/**
2121
* @var ExtractAssetsFromContentInterface
2222
*/
23-
private $service;
23+
private $extractAssetsFromContent;
2424

2525
/**
2626
* @inheritdoc
2727
*/
2828
public function setUp(): void
2929
{
30-
$this->service = Bootstrap::getObjectManager()->get(ExtractAssetsFromContentInterface::class);
30+
$this->extractAssetsFromContent = Bootstrap::getObjectManager()
31+
->get(ExtractAssetsFromContentInterface::class);
3132
}
3233

3334
/**
@@ -41,7 +42,7 @@ public function setUp(): void
4142
*/
4243
public function testExecute(string $content, array $assetIds): void
4344
{
44-
$assets = $this->service->execute($content);
45+
$assets = $this->extractAssetsFromContent->execute($content);
4546

4647
$extractedAssetIds = [];
4748
foreach ($assets as $asset) {

dev/tests/integration/testsuite/Magento/MediaContent/Model/AssignGetUnassignTest.php renamed to dev/tests/integration/testsuite/Magento/MediaContent/Model/SaveDeleteContentAssetLinksTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* Test for AssignAssets service
2222
*/
23-
class AssignGetUnassignTest extends TestCase
23+
class SaveDeleteContentAssetLinksTest extends TestCase
2424
{
2525
/**
2626
* @var SaveContentAssetLinksInterface
@@ -55,7 +55,7 @@ public function setUp(): void
5555
}
5656

5757
/**
58-
* Assing assets to content, retrieve the data, then unassign assets from content
58+
* Save asset to content links, retrieve the data, delete assets to content links
5959
*/
6060
public function testAssignRetrieveAndUnassign(): void
6161
{

0 commit comments

Comments
 (0)