Skip to content

Commit

Permalink
OP-325: spec, unit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Jul 3, 2024
1 parent 61b26ee commit a9a5fdf
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 85 deletions.
15 changes: 3 additions & 12 deletions spec/Entity/MediaSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public function it_allows_access_via_properties(): void
$this->setCode('file');
$this->getCode()->shouldReturn('file');

$this->setName('Video');
$this->getName()->shouldReturn('Video');

$this->setType('video');
$this->getType()->shouldReturn('video');

Expand All @@ -65,18 +68,6 @@ public function it_toggles(): void
$this->isEnabled()->shouldReturn(false);
}

public function it_associates_products(ProductInterface $firstProduct, ProductInterface $secondProduct): void
{
$this->addProduct($firstProduct);
$this->hasProduct($firstProduct)->shouldReturn(true);

$this->hasProduct($secondProduct)->shouldReturn(false);

$this->removeProduct($firstProduct);

$this->hasProduct($firstProduct)->shouldReturn(false);
}

public function it_associates_collections(CollectionInterface $firstCollection, CollectionInterface $secondCollection): void
{
$this->addCollection($firstCollection);
Expand Down
3 changes: 0 additions & 3 deletions spec/Entity/MediaTranslationSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public function it_implements_media_translation_interface(): void

public function it_allows_access_via_properties(): void
{
$this->setName('Video');
$this->getName()->shouldReturn('Video');

$this->setContent('Lorem ipsum');
$this->getContent()->shouldReturn('Lorem ipsum');

Expand Down
4 changes: 0 additions & 4 deletions spec/Importer/MediaImporterSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ public function let(
ResourceResolverInterface $mediaResourceResolver,
LocaleContextInterface $localeContext,
ImporterCollectionsResolverInterface $importerCollectionsResolver,
ImporterProductsResolverInterface $importerProductsResolver,
ValidatorInterface $validator,
MediaRepositoryInterface $mediaRepository
) {
$this->beConstructedWith(
$mediaResourceResolver,
$localeContext,
$importerCollectionsResolver,
$importerProductsResolver,
$validator,
$mediaRepository,
);
Expand All @@ -50,7 +48,6 @@ public function it_imports_media(
ResourceResolverInterface $mediaResourceResolver,
LocaleContextInterface $localeContext,
ImporterCollectionsResolverInterface $importerCollectionsResolver,
ImporterProductsResolverInterface $importerProductsResolver,
ValidatorInterface $validator,
MediaRepositoryInterface $mediaRepository,
MediaInterface $media
Expand All @@ -70,7 +67,6 @@ public function it_imports_media(
$media->setAlt('alt')->shouldBeCalled();

$importerCollectionsResolver->resolve($media, null)->shouldBeCalled();
$importerProductsResolver->resolve($media, null)->shouldBeCalled();

$validator->validate($media, null, ['bitbag'])->willReturn(new ConstraintViolationList());

Expand Down
1 change: 0 additions & 1 deletion src/Resources/config/api_resources/Media.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
<property name="height" identifier="false" writable="false"/>
<property name="saveWithOriginalName" identifier="false" writable="false"/>
<property name="collections" identifier="false" writable="false"/>
<property name="products" identifier="false" writable="false"/>
<property name="channels" identifier="false" writable="false"/>
</resource>
</resources>
12 changes: 3 additions & 9 deletions tests/Functional/DataFixtures/ORM/Api/MediaTest/media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,24 @@ Sylius\Component\Core\Model\ProductVariant:

BitBag\SyliusCmsPlugin\Entity\MediaTranslation:
media1_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
media2_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
media3_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
BitBag\SyliusCmsPlugin\Entity\Media:
media1:
code: 'media1-code'
name: 'media1-name'
enabled: true
type: 'image'
path: '/path/to/media1'
products:
- '@product1'
collections:
- '@collection1'
channels:
Expand All @@ -104,11 +100,10 @@ BitBag\SyliusCmsPlugin\Entity\Media:
- '@media1_translation'
media2:
code: 'media2-code'
name: 'media2-name'
enabled: true
type: 'image'
path: '/path/to/media2'
products:
- '@product2'
collections:
- '@collection2'
channels:
Expand All @@ -117,11 +112,10 @@ BitBag\SyliusCmsPlugin\Entity\Media:
- '@media2_translation'
media3:
code: 'media3-code'
name: 'media3-name'
enabled: false
type: 'image'
path: '/path/to/media3'
products:
- '@product3'
collections:
- '@collection3'
channels:
Expand Down
16 changes: 4 additions & 12 deletions tests/Functional/Fixture/MediaFixtureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,29 +122,21 @@ public function custom_may_contain_name(): void
[
'custom' => [
'media_1' => [
'translations' => [
'en_US' => [
'name' => 'My media',
],
],
'name' => 'My media',
],
],
],
], 'custom.*.translations.*.name');
], 'custom.*.name');

$this->assertConfigurationIsValid([
[
'custom' => [
'media_1' => [
'translations' => [
'en_US' => [
'name' => '',
],
],
'name' => '',
],
],
],
], 'custom.*.translations.*.name');
], 'custom.*.name');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"id": "@integer@",
"type": "image",
"code": "media1-code",
"name": "media1-name",
"path": "/path/to/media1",
"mimeType": null,
"width": null,
Expand All @@ -23,16 +24,12 @@
"code": "collection1-code"
}
],
"products": [
"/api/v2/shop/products/MUG_SW"
],
"channels": [
"/api/v2/shop/channels/code"
],
"translations": {
"en_US": {
"@type": "MediaTranslation",
"name": "translation_name_en_US",
"content": "translation_content_en_US",
"alt": null,
"link": "translation_link_en_US"
Expand All @@ -45,6 +42,7 @@
"id": "@integer@",
"type": "image",
"code": "media2-code",
"name": "media2-name",
"path": "/path/to/media2",
"mimeType": null,
"width": null,
Expand All @@ -59,16 +57,12 @@
"code": "collection2-code"
}
],
"products": [
"/api/v2/shop/products/MUG_SW2"
],
"channels": [
"/api/v2/shop/channels/code"
],
"translations": {
"en_US": {
"@type": "MediaTranslation",
"name": "translation_name_en_US",
"content": "translation_content_en_US",
"alt": null,
"link": "translation_link_en_US"
Expand All @@ -81,6 +75,7 @@
"id": "@integer@",
"type": "image",
"code": "media3-code",
"name": "media3-name",
"path": "/path/to/media3",
"mimeType": null,
"width": null,
Expand All @@ -95,16 +90,12 @@
"code": "collection3-code"
}
],
"products": [
"/api/v2/shop/products/MUG_SW3"
],
"channels": [
"/api/v2/shop/channels/code"
],
"translations": {
"en_US": {
"@type": "MediaTranslation",
"name": "translation_name_en_US",
"content": "translation_content_en_US",
"alt": null,
"link": "translation_link_en_US"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"id": "@integer@",
"type": "image",
"code": "media1-code",
"name": "media1-name",
"path": "/path/to/media1",
"mimeType": null,
"width": null,
Expand All @@ -19,16 +20,12 @@
"code": "collection1-code"
}
],
"products": [
"/api/v2/shop/products/MUG_SW"
],
"channels": [
"/api/v2/shop/channels/code"
],
"translations": {
"en_US": {
"@type": "MediaTranslation",
"name": "translation_name_en_US",
"content": "translation_content_en_US",
"alt": null,
"link": "translation_link_en_US"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@ Sylius\Component\Core\Model\Channel:
base_currency: '@dollar'
BitBag\SyliusCmsPlugin\Entity\MediaTranslation:
media1_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
media2_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
media3_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
BitBag\SyliusCmsPlugin\Entity\Media:
media1:
code: 'media1-code'
name: 'media1-name'
enabled: true
type: 'image'
path: '/path/to/media1'
Expand All @@ -45,6 +43,7 @@ BitBag\SyliusCmsPlugin\Entity\Media:
- '@media1_translation'
media2:
code: 'media2-code'
name: 'media2-name'
enabled: true
type: 'image'
path: '/path/to/media2'
Expand All @@ -54,6 +53,7 @@ BitBag\SyliusCmsPlugin\Entity\Media:
- '@media2_translation'
media3:
code: 'media3-code'
name: 'media3-name'
enabled: false
type: 'image'
path: '/path/to/media3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,21 @@ Sylius\Component\Core\Model\Channel:
base_currency: '@dollar'
BitBag\SyliusCmsPlugin\Entity\MediaTranslation:
media1_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
media2_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
media3_translation:
name: 'translation_name_en_US'
locale: 'en_US'
content: 'translation_content_en_US'
link: 'translation_link_en_US'
BitBag\SyliusCmsPlugin\Entity\Media:
media1:
code: 'media1-code'
name: 'media1-name'
enabled: true
type: 'image'
path: '/path/to/media1'
Expand All @@ -47,6 +45,7 @@ BitBag\SyliusCmsPlugin\Entity\Media:
- '@media1_translation'
media2:
code: 'media2-code'
name: 'media2-name'
enabled: true
type: 'image'
path: '/path/to/media2'
Expand All @@ -58,6 +57,7 @@ BitBag\SyliusCmsPlugin\Entity\Media:
- '@media2_translation'
media3:
code: 'media3-code'
name: 'media3-name'
enabled: false
type: 'image'
path: '/path/to/media3'
Expand Down
Loading

0 comments on commit a9a5fdf

Please sign in to comment.