Skip to content

Commit

Permalink
OP-322: Tests adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Jul 1, 2024
1 parent be82c22 commit b547cda
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 90 deletions.
42 changes: 0 additions & 42 deletions spec/Entity/CollectionTranslationSpec.php

This file was deleted.

1 change: 0 additions & 1 deletion src/Resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ parameters:
bitbag_sylius_cms_plugin.form.type.frequently_asked_question.validation_groups: "%bitbag_validation_group%"
bitbag_sylius_cms_plugin.form.type.translation.frequently_asked_question.validation_groups: "%bitbag_validation_group%"
bitbag_sylius_cms_plugin.form.type.collection.validation_groups: "%bitbag_validation_group%"
bitbag_sylius_cms_plugin.form.type.translation.collection.validation_groups: "%bitbag_validation_group%"
bitbag_sylius_cms_plugin.form.type.translation.media.validation_groups: "%bitbag_validation_group%"
bitbag_sylius_cms_plugin.form.type.media.validation_groups: "%bitbag_validation_group%"
bitbag_sylius_cms_plugin.uploader.filesystem: bitbag_sylius_cms_plugin_media
Expand Down
3 changes: 0 additions & 3 deletions src/Resources/config/serialization/Block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
<attribute name="taxons">
<group>shop:cms:read</group>
</attribute>
<attribute name="translations">
<group>shop:cms:read</group>
</attribute>
<attribute name="contentElements">
<group>shop:cms:read</group>
</attribute>
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Api/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function setUp(): void
public function test_collection_response(): void
{
/** @var CollectionInterface $collection */
$collection = $this->getRepository()->findOneByCode('collection1-code', 'en_US');
$collection = $this->getRepository()->findOneByCode('collection1-code');
$this->client->request('GET', '/api/v2/shop/cms-plugin/collections/' . $collection->getId(), [], [], self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ Sylius\Component\Core\Model\Channel:
BitBag\SyliusCmsPlugin\Entity\Collection:
collection1:
code: 'collection1-code'
translations:
- '@collection1_translation'
name: 'collection1-name'
collection2:
code: 'collection2-code'
translations:
- '@collection2_translation'
name: 'collection2-name'
collection3:
code: 'collection3-code'
translations:
- '@collection3_translation'
name: 'collection3-name'
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ Sylius\Component\Core\Model\Channel:
BitBag\SyliusCmsPlugin\Entity\Collection:
collection1:
code: 'collection1-code'
translations:
- '@collection1_translation'
collection2:
code: 'collection2-code'
translations:
- '@collection2_translation'
collection3:
code: 'collection3-code'
translations:
- '@collection3_translation'
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ Sylius\Component\Core\Model\Channel:
BitBag\SyliusCmsPlugin\Entity\Collection:
collection1:
code: 'collection1-code'
translations:
- '@collection1_translation'
collection2:
code: 'collection2-code'
translations:
- '@collection2_translation'
collection3:
code: 'collection3-code'
translations:
- '@collection3_translation'
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ Sylius\Component\Core\Model\Channel:
BitBag\SyliusCmsPlugin\Entity\Collection:
collection1:
code: 'collection1-code'
translations:
- '@collection1_translation'
name: 'collection1-name'
collection2:
code: 'collection2-code'
translations:
- '@collection2_translation'
name: 'collection2-name'
collection3:
code: 'collection3-code'
translations:
- '@collection3_translation'
name: 'collection3-name'
20 changes: 3 additions & 17 deletions tests/Integration/Repository/CollectionRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use ApiTestCase\JsonApiTestCase;
use BitBag\SyliusCmsPlugin\Entity\CollectionInterface;
use BitBag\SyliusCmsPlugin\Repository\CollectionRepositoryInterface;
use Doctrine\ORM\QueryBuilder;

final class CollectionRepositoryTest extends JsonApiTestCase
{
Expand All @@ -23,26 +22,14 @@ public function setUp(): void
parent::setUp();
}

public function test_it_creates_list_query_builder(): void
{
$repository = $this->getRepository();

$localeCode = 'en_US';
$queryBuilder = $repository->createListQueryBuilder($localeCode);

self::assertInstanceOf(QueryBuilder::class, $queryBuilder);
self::assertNotNull($queryBuilder->getQuery());
}

public function test_it_finds_collection_by_name_part(): void
{
$this->loadFixturesFromFile('CollectionRepositoryTest/test_it_finds_collection_by_name.yml');

$repository = $this->getRepository();

$phrase = 'translation';
$locale = 'en_US';
$collections = $repository->findByNamePart($phrase, $locale);
$phrase = 'collection';
$collections = $repository->findByNamePart($phrase);

self::assertIsArray($collections);
self::assertCount(3, $collections);
Expand All @@ -68,8 +55,7 @@ public function test_it_finds_by_codes_and_locale(): void
$repository = $this->getRepository();

$codes = 'collection1-code,collection2-code';
$localeCode = 'en_US';
$collections = $repository->findByCodesAndLocale($codes, $localeCode);
$collections = $repository->findByCodes($codes);

self::assertIsArray($collections);
self::assertCount(2, $collections);
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Repository/PageRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function test_it_finds_enabled_page_by_collection_code(): void

$pageRepository = $this->getRepository();

$page1_array = $pageRepository->findByCollectionCode('collection1-code', 'en_US');
$page3_array = $pageRepository->findByCollectionCode('collection3-code', 'en_US');
$page1_array = $pageRepository->findByCollectionCode('collection1-code');
$page3_array = $pageRepository->findByCollectionCode('collection3-code');

self::assertNotEmpty($page1_array);
self::assertEmpty($page3_array);
Expand Down

0 comments on commit b547cda

Please sign in to comment.