{% for child in form %}
@@ -201,7 +201,7 @@
{{ empty_message|default('Nothing to choose from.'|trans) }}
{% endfor %}
- {% endspaceless %}
+ {% endapply %}
{% endblock choice_widget_expanded %}
{% block widget_attributes -%}
@@ -257,14 +257,14 @@
{% endblock honey_pot_row %}
{% block date_picker_widget %}
- {% spaceless %}
+ {% apply spaceless %}
{% set attr = attr|merge({'class': ((attr.class|default('') ~ ' js-date-picker')|trim)}) %}
{{- block('form_widget') -}}
- {% endspaceless %}
+ {% endapply %}
{% endblock date_picker_widget %}
{% block icon %}
- {% spaceless %}
+ {% apply spaceless %}
{% if icon is defined %}
{% endif %}
- {% endspaceless %}
+ {% endapply %}
{% endblock %}
diff --git a/templates/Front/Layout/layout.html.twig b/templates/Front/Layout/layout.html.twig
index 3f5d089922..ec1aa21f38 100644
--- a/templates/Front/Layout/layout.html.twig
+++ b/templates/Front/Layout/layout.html.twig
@@ -2,7 +2,7 @@
{% use 'Front/Layout/header.html.twig' %}
{% block html_body %}
- {% set adminLoggedAsCustomer = is_granted(constant('Shopsys\\FrameworkBundle\\Model\\Security\\Roles::ROLE_ADMIN_AS_CUSTOMER')) %}
+ {% set adminLoggedAsCustomer = app.session.has(constant('Shopsys\\FrameworkBundle\\Model\\Security\\LoginAsUserFacade::SESSION_LOGIN_AS')) %}
{% if adminLoggedAsCustomer or isMailerSettingUnusual() %}
{% if adminLoggedAsCustomer %}
diff --git a/tests/App/Acceptance/acceptance/_bootstrap.php b/tests/App/Acceptance/acceptance/_bootstrap.php
deleted file mode 100644
index c72c43dede..0000000000
--- a/tests/App/Acceptance/acceptance/_bootstrap.php
+++ /dev/null
@@ -1,5 +0,0 @@
-getEntityManager()->createQueryBuilder()
+ $qb = $this->em->createQueryBuilder()
->select('o, oi')
->from(Order::class, 'o')
->join(OrderItem::class, 'oi', Join::WITH, 'oi.order = o')
@@ -23,14 +23,14 @@ public function testHydrateAllData()
$rows = $qb->getQuery()->execute(null, GroupedScalarHydrator::HYDRATION_MODE);
$row = $rows[0];
- $this->assertInternalType('array', $row);
+ $this->assertIsArray($row);
$this->assertCount(2, $row);
$this->assertArrayHasKey('o', $row);
$this->assertArrayHasKey('oi', $row);
- $this->assertInternalType('array', $row['o']);
- $this->assertInternalType('array', $row['oi']);
+ $this->assertIsArray($row['o']);
+ $this->assertIsArray($row['oi']);
$this->assertArrayHasKey('id', $row['o']);
$this->assertArrayHasKey('id', $row['oi']);
diff --git a/tests/App/Functional/Component/Doctrine/SortableNullsWalkerTest.php b/tests/App/Functional/Component/Doctrine/SortableNullsWalkerTest.php
index 39299bb615..f8326d77a8 100644
--- a/tests/App/Functional/Component/Doctrine/SortableNullsWalkerTest.php
+++ b/tests/App/Functional/Component/Doctrine/SortableNullsWalkerTest.php
@@ -7,16 +7,14 @@
use App\Model\Product\Product;
use Doctrine\ORM\Query;
use Shopsys\FrameworkBundle\Component\Doctrine\SortableNullsWalker;
-use Tests\App\Test\FunctionalTestCase;
+use Tests\App\Test\TransactionFunctionalTestCase;
-class SortableNullsWalkerTest extends FunctionalTestCase
+class SortableNullsWalkerTest extends TransactionFunctionalTestCase
{
public function testWalkOrderByItemAsc()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
- $queryBuilder = $em->createQueryBuilder();
+ $queryBuilder = $this->em->createQueryBuilder();
$queryBuilder
->select('p.id')
@@ -31,10 +29,8 @@ public function testWalkOrderByItemAsc()
public function testWalkOrderByItemDesc()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
- $queryBuilder = $em->createQueryBuilder();
+ $queryBuilder = $this->em->createQueryBuilder();
$queryBuilder
->select('p.id')
@@ -49,10 +45,8 @@ public function testWalkOrderByItemDesc()
public function testWalkOrderByItemWithoutOrdering()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
/** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
- $queryBuilder = $em->createQueryBuilder();
+ $queryBuilder = $this->em->createQueryBuilder();
$queryBuilder
->select('p.id')
diff --git a/tests/App/Functional/Component/Domain/Multidomain/MultidomainEntityDataCreatorTest.php b/tests/App/Functional/Component/Domain/Multidomain/MultidomainEntityDataCreatorTest.php
index df39d06a5d..e45883d4b9 100644
--- a/tests/App/Functional/Component/Domain/Multidomain/MultidomainEntityDataCreatorTest.php
+++ b/tests/App/Functional/Component/Domain/Multidomain/MultidomainEntityDataCreatorTest.php
@@ -13,10 +13,7 @@ class MultidomainEntityDataCreatorTest extends TransactionFunctionalTestCase
{
public function testCopyAllMultidomainDataForNewDomainCopiesTestRow()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
-
- $em->getConnection()->executeQuery('
+ $this->em->getConnection()->executeQuery('
CREATE TABLE _test_table (
domain_id int NOT NULL,
title text NOT NULL,
@@ -24,7 +21,7 @@ public function testCopyAllMultidomainDataForNewDomainCopiesTestRow()
)
');
- $em->getConnection()->executeQuery("
+ $this->em->getConnection()->executeQuery("
INSERT INTO _test_table (domain_id, title, description)
VALUES (1, 'asdf', 'qwer')
");
@@ -40,13 +37,13 @@ public function testCopyAllMultidomainDataForNewDomainCopiesTestRow()
'_test_table' => ['title'],
]);
- $sqlQuoter = new SqlQuoter($em);
+ $sqlQuoter = new SqlQuoter($this->em);
- $multidomainEntityDataCreator = new MultidomainEntityDataCreator($multidomainEntityClassFinderFacadeMock, $em, $sqlQuoter);
+ $multidomainEntityDataCreator = new MultidomainEntityDataCreator($multidomainEntityClassFinderFacadeMock, $this->em, $sqlQuoter);
$multidomainEntityDataCreator->copyAllMultidomainDataForNewDomain(1, 2);
- $results = $em->getConnection()->fetchAll('
+ $results = $this->em->getConnection()->fetchAll('
SELECT domain_id, title, description
FROM _test_table
ORDER BY domain_id
@@ -70,17 +67,14 @@ public function testCopyAllMultidomainDataForNewDomainCopiesTestRow()
public function testCopyAllMultidomainDataForNewDomainWithDomainIdDoesNotThrowDriverException()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
-
- $em->getConnection()->executeQuery('
+ $this->em->getConnection()->executeQuery('
CREATE TABLE _test_table (
domain_id int NOT NULL,
title text NOT NULL
)
');
- $em->getConnection()->executeQuery("
+ $this->em->getConnection()->executeQuery("
INSERT INTO _test_table (domain_id, title)
VALUES (1, 'asdf')
");
@@ -96,9 +90,9 @@ public function testCopyAllMultidomainDataForNewDomainWithDomainIdDoesNotThrowDr
'_test_table' => ['domain_id', 'title'],
]);
- $sqlQuoter = new SqlQuoter($em);
+ $sqlQuoter = new SqlQuoter($this->em);
- $multidomainEntityDataCreator = new MultidomainEntityDataCreator($multidomainEntityClassFinderFacadeMock, $em, $sqlQuoter);
+ $multidomainEntityDataCreator = new MultidomainEntityDataCreator($multidomainEntityClassFinderFacadeMock, $this->em, $sqlQuoter);
try {
$multidomainEntityDataCreator->copyAllMultidomainDataForNewDomain(1, 2);
diff --git a/tests/App/Functional/Component/FlashMessage/BagTest.php b/tests/App/Functional/Component/FlashMessage/BagTest.php
deleted file mode 100644
index 50ab960718..0000000000
--- a/tests/App/Functional/Component/FlashMessage/BagTest.php
+++ /dev/null
@@ -1,87 +0,0 @@
-getContainer()->get('shopsys.shop.component.flash_message.bag.admin');
- /** @var \Shopsys\FrameworkBundle\Component\FlashMessage\Bag $flashMessageFront */
- $flashMessageFront = $this->getContainer()->get('shopsys.shop.component.flash_message.bag.front');
-
- $errorMessageAdmin = 'Error message admin';
- $errorMessageFront = 'Error message front';
- $successMessageAdmin = 'Success message admin';
-
- $flashMessageAdmin->addError($errorMessageAdmin);
- $flashMessageAdmin->addSuccess($successMessageAdmin);
- $flashMessageFront->addError($errorMessageFront);
-
- $this->assertSame([$errorMessageAdmin], $flashMessageAdmin->getErrorMessages());
- $this->assertSame([], $flashMessageAdmin->getInfoMessages());
- $this->assertSame([$successMessageAdmin], $flashMessageAdmin->getSuccessMessages());
- $this->assertSame([$errorMessageFront], $flashMessageFront->getErrorMessages());
- $this->assertSame([], $flashMessageFront->getInfoMessages());
- $this->assertSame([], $flashMessageFront->getSuccessMessages());
- }
-
- public function testAddArrayOfMessages()
- {
- /** @var \Shopsys\FrameworkBundle\Component\FlashMessage\Bag $flashMessageAdmin */
- $flashMessageAdmin = $this->getContainer()->get('shopsys.shop.component.flash_message.bag.admin');
-
- $errorMessagesAdmin = ['First error message admin', 'Second error message admin'];
-
- $flashMessageAdmin->addError($errorMessagesAdmin);
-
- $this->assertSame($errorMessagesAdmin, $flashMessageAdmin->getErrorMessages());
- }
-
- public function testGetUniqueMessage()
- {
- /** @var \Shopsys\FrameworkBundle\Component\FlashMessage\Bag $flashMessageAdmin */
- $flashMessageAdmin = $this->getContainer()->get('shopsys.shop.component.flash_message.bag.admin');
-
- $errorMessageAdmin = 'Error message admin';
-
- $flashMessageAdmin->addError($errorMessageAdmin);
- $flashMessageAdmin->addError($errorMessageAdmin);
-
- $this->assertSame([$errorMessageAdmin], $flashMessageAdmin->getErrorMessages());
- }
-
- public function testGetAndClearBag()
- {
- /** @var \Shopsys\FrameworkBundle\Component\FlashMessage\Bag $flashMessageAdmin */
- $flashMessageAdmin = $this->getContainer()->get('shopsys.shop.component.flash_message.bag.admin');
-
- $errorMessageAdmin = 'Error message admin';
-
- $flashMessageAdmin->addError($errorMessageAdmin);
-
- $this->assertSame([$errorMessageAdmin], $flashMessageAdmin->getErrorMessages());
- $this->assertSame([], $flashMessageAdmin->getErrorMessages());
- }
-
- public function testIsEmpty()
- {
- /** @var \Shopsys\FrameworkBundle\Component\FlashMessage\Bag $flashMessageAdmin */
- $flashMessageAdmin = $this->getContainer()->get('shopsys.shop.component.flash_message.bag.admin');
-
- // clearing after previous tests
- $flashMessageAdmin->getErrorMessages();
- $flashMessageAdmin->getInfoMessages();
- $flashMessageAdmin->getSuccessMessages();
-
- $this->assertTrue($flashMessageAdmin->isEmpty());
- $flashMessageAdmin->addInfo('Some message');
- $this->assertFalse($flashMessageAdmin->isEmpty());
- $this->assertFalse($flashMessageAdmin->isEmpty(), 'Flash message cannot modified content after call isEmpty()');
- }
-}
diff --git a/tests/App/Functional/Component/Grid/Ordering/GridOrderingFacadeTest.php b/tests/App/Functional/Component/Grid/Ordering/GridOrderingFacadeTest.php
index 1681ffba6b..615c7856a8 100644
--- a/tests/App/Functional/Component/Grid/Ordering/GridOrderingFacadeTest.php
+++ b/tests/App/Functional/Component/Grid/Ordering/GridOrderingFacadeTest.php
@@ -12,9 +12,7 @@ class GridOrderingFacadeTest extends TransactionFunctionalTestCase
{
public function testSetPositionWrongEntity()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
- $gridOrderingFacade = new GridOrderingFacade($em);
+ $gridOrderingFacade = new GridOrderingFacade($this->em);
$entity = new stdClass();
$this->expectException(\Shopsys\FrameworkBundle\Component\Grid\Ordering\Exception\EntityIsNotOrderableException::class);
$gridOrderingFacade->saveOrdering($entity, []);
diff --git a/tests/App/Functional/Component/Grid/QueryBuilderDataSourceTest.php b/tests/App/Functional/Component/Grid/QueryBuilderDataSourceTest.php
index 7e3c2b5342..36f85adf3d 100644
--- a/tests/App/Functional/Component/Grid/QueryBuilderDataSourceTest.php
+++ b/tests/App/Functional/Component/Grid/QueryBuilderDataSourceTest.php
@@ -13,10 +13,7 @@ class QueryBuilderDataSourceTest extends TransactionFunctionalTestCase
{
public function testGetOneRow()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p');
@@ -24,16 +21,13 @@ public function testGetOneRow()
$row = $queryBuilderDataSource->getOneRow($this->getReference(ProductDataFixture::PRODUCT_PREFIX . '1'));
- $this->assertInternalType('array', $row);
+ $this->assertIsArray($row);
$this->assertArrayHasKey('p', $row);
}
public function testGetTotalRowsCount()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p')
->where('p.id >= 1 AND p.id <= 10')
@@ -49,10 +43,7 @@ public function testGetTotalRowsCount()
public function testGetRows()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p')
->setMaxResults(5);
@@ -60,21 +51,18 @@ public function testGetRows()
$queryBuilderDataSource = new QueryBuilderDataSource($qb, 'p.id');
$rows = $queryBuilderDataSource->getPaginatedRows()->getResults();
- $this->assertInternalType('array', $rows);
+ $this->assertIsArray($rows);
$this->assertCount(5, $rows);
foreach ($rows as $row) {
- $this->assertInternalType('array', $row);
+ $this->assertIsArray($row);
$this->assertArrayHasKey('p', $row);
}
}
public function testGetRowsInAscOrder()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p')
->setMaxResults(10);
@@ -96,10 +84,7 @@ public function testGetRowsInAscOrder()
public function testGetRowsInDescOrder()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p')
->setMaxResults(10);
diff --git a/tests/App/Functional/Component/Grid/QueryBuilderWithRowManipulatorDataSourceTest.php b/tests/App/Functional/Component/Grid/QueryBuilderWithRowManipulatorDataSourceTest.php
index 0f17ea0413..616be0a62b 100644
--- a/tests/App/Functional/Component/Grid/QueryBuilderWithRowManipulatorDataSourceTest.php
+++ b/tests/App/Functional/Component/Grid/QueryBuilderWithRowManipulatorDataSourceTest.php
@@ -13,10 +13,7 @@ class QueryBuilderWithRowManipulatorDataSourceTest extends TransactionFunctional
{
public function testGetOneRow()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p');
@@ -27,17 +24,14 @@ public function testGetOneRow()
$row = $dataSource->getOneRow($this->getReference(ProductDataFixture::PRODUCT_PREFIX . '1'));
- $this->assertInternalType('array', $row);
+ $this->assertIsArray($row);
$this->assertArrayHasKey('newField', $row);
$this->assertSame('newValue', $row['newField']);
}
public function testGetTotalRowsCount()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p')
->where('p.id >= 1 AND p.id <= 10')
@@ -56,10 +50,7 @@ public function testGetTotalRowsCount()
public function testGetRows()
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.entity_manager');
-
- $qb = $em->createQueryBuilder();
+ $qb = $this->em->createQueryBuilder();
$qb->select('p')
->from(Product::class, 'p')
->setMaxResults(5);
@@ -70,11 +61,11 @@ public function testGetRows()
});
$rows = $dataSource->getPaginatedRows()->getResults();
- $this->assertInternalType('array', $rows);
+ $this->assertIsArray($rows);
$this->assertCount(5, $rows);
foreach ($rows as $row) {
- $this->assertInternalType('array', $row);
+ $this->assertIsArray($row);
$this->assertArrayHasKey('newField', $row);
$this->assertSame('newValue' . $row['p']['id'], $row['newField']);
}
diff --git a/tests/App/Functional/Component/HttpFoundation/FragmentHandlerTest.php b/tests/App/Functional/Component/HttpFoundation/FragmentHandlerTest.php
index f62cc37648..eb99f860c9 100644
--- a/tests/App/Functional/Component/HttpFoundation/FragmentHandlerTest.php
+++ b/tests/App/Functional/Component/HttpFoundation/FragmentHandlerTest.php
@@ -8,31 +8,40 @@
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class FragmentHandlerTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
+ /**
+ * @var \Symfony\Bridge\Twig\Extension\HttpKernelRuntime
+ * @inject
+ */
+ private $httpKernelRuntime;
+
+ /**
+ * @var \Symfony\Component\HttpFoundation\RequestStack
+ * @inject
+ */
+ private $requestStack;
+
public function testRenderingFragmentDoesNotIgnoreException()
{
- /** @var \Symfony\Bridge\Twig\Extension\HttpKernelRuntime $httpKernelRuntime */
- $httpKernelRuntime = $this->getContainer()->get('twig.runtime.httpkernel');
-
// Rendering a fragment can only be done when handling a Request.
$this->putFakeRequestToRequestStack();
$this->expectException(\App\Controller\Test\ExpectedTestException::class);
/** This should call @see \Shopsys\FrameworkBundle\Component\HttpFoundation\FragmentHandler::render() */
- $httpKernelRuntime->renderFragment('/test/error-handler/exception');
+ $this->httpKernelRuntime->renderFragment('/test/error-handler/exception');
}
private function putFakeRequestToRequestStack()
{
- /** @var \Symfony\Component\HttpFoundation\RequestStack $requestStack */
- $requestStack = $this->getContainer()->get('request_stack');
-
$request = new Request();
$session = new Session(new MockArraySessionStorage());
$request->setSession($session);
- $requestStack->push($request);
+ $this->requestStack->push($request);
}
}
diff --git a/tests/App/Functional/Controller/HomepageControllerTest.php b/tests/App/Functional/Controller/HomepageControllerTest.php
index ece4270452..862dae8b58 100644
--- a/tests/App/Functional/Controller/HomepageControllerTest.php
+++ b/tests/App/Functional/Controller/HomepageControllerTest.php
@@ -10,7 +10,7 @@ class HomepageControllerTest extends FunctionalTestCase
{
public function testHomepageHttpStatus200()
{
- $client = $this->getClient();
+ $client = $this->findClient();
$client->request('GET', '/');
$code = $client->getResponse()->getStatusCode();
@@ -20,7 +20,7 @@ public function testHomepageHttpStatus200()
public function testHomepageHasBodyEnd()
{
- $client = $this->getClient();
+ $client = $this->findClient();
$client->request('GET', '/');
$content = $client->getResponse()->getContent();
diff --git a/tests/App/Functional/Controller/ProductRenameRedirectPreviousUrlTest.php b/tests/App/Functional/Controller/ProductRenameRedirectPreviousUrlTest.php
index ee44b862bf..9f874279ac 100644
--- a/tests/App/Functional/Controller/ProductRenameRedirectPreviousUrlTest.php
+++ b/tests/App/Functional/Controller/ProductRenameRedirectPreviousUrlTest.php
@@ -5,12 +5,16 @@
namespace Tests\App\Functional\Controller;
use App\DataFixtures\Demo\ProductDataFixture;
+use Faker\Provider\Text;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
-use Tests\App\Test\TransactionFunctionalTestCase;
+use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
-class ProductRenameRedirectPreviousUrlTest extends TransactionFunctionalTestCase
+class ProductRenameRedirectPreviousUrlTest extends FunctionalTestCase
{
- private const TESTED_PRODUCT_ID = 1;
+ use SymfonyTestContainer;
+
+ private const TESTED_PRODUCT_ID = 100;
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductDataFactoryInterface
@@ -30,19 +34,27 @@ class ProductRenameRedirectPreviousUrlTest extends TransactionFunctionalTestCase
*/
private $friendlyUrlFacade;
+ /**
+ * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
+ * @inject
+ */
+ protected $em;
+
public function testPreviousUrlRedirect(): void
{
+ /** @var \App\Model\Product\Product $product */
$product = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . self::TESTED_PRODUCT_ID);
$previousFriendlyUrlSlug = $this->friendlyUrlFacade->findMainFriendlyUrl(Domain::FIRST_DOMAIN_ID, 'front_product_detail', self::TESTED_PRODUCT_ID)->getSlug();
- /** @var \App\Model\Product\Product $product */
$productData = $this->productDataFactory->createFromProduct($product);
- $productData->name[$this->domain->getDomainConfigById(Domain::FIRST_DOMAIN_ID)->getLocale()] = 'rename';
+ $productData->name[$this->domain->getDomainConfigById(Domain::FIRST_DOMAIN_ID)->getLocale()] = Text::asciify();
$this->productFacade->edit(self::TESTED_PRODUCT_ID, $productData);
- $client = $this->getClient();
+ $overWriteDomainUrl = preg_replace('#^https?://#', '', $this->getContainer()->getParameter('overwrite_domain_url'));
+
+ $client = $this->findClient(true, null, null, [], ['HTTP_HOST' => $overWriteDomainUrl]);
$client->request('GET', '/' . $previousFriendlyUrlSlug);
// Should be 301 (moved permanently), because old product urls should be permanently redirected
diff --git a/tests/App/Functional/EntityExtension/EntityExtensionTest.php b/tests/App/Functional/EntityExtension/EntityExtensionTest.php
index d33dd32140..553ff19ad3 100644
--- a/tests/App/Functional/EntityExtension/EntityExtensionTest.php
+++ b/tests/App/Functional/EntityExtension/EntityExtensionTest.php
@@ -4,17 +4,17 @@
namespace Tests\App\Functional\EntityExtension;
-use App\Model\Category\Category;
-use App\Model\Order\Order;
use App\Model\Order\Order as ExtendedOrder;
use App\Model\Product\Brand\Brand as ExtendedBrand;
-use App\Model\Product\Product;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Tools\SchemaTool;
+use Shopsys\FrameworkBundle\Model\Category\Category;
use Shopsys\FrameworkBundle\Model\Order\Item\OrderItem;
+use Shopsys\FrameworkBundle\Model\Order\Order;
use Shopsys\FrameworkBundle\Model\Product\Brand\Brand;
+use Shopsys\FrameworkBundle\Model\Product\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductTranslation;
use Tests\App\Functional\EntityExtension\Model\CategoryManyToManyBidirectionalEntity;
use Tests\App\Functional\EntityExtension\Model\CategoryOneToManyBidirectionalEntity;
@@ -28,9 +28,12 @@
use Tests\App\Functional\EntityExtension\Model\ProductOneToOneBidirectionalEntity;
use Tests\App\Functional\EntityExtension\Model\UnidirectionalEntity;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class EntityExtensionTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const MAIN_PRODUCT_ID = 1;
protected const ONE_TO_ONE_SELF_REFERENCING_PRODUCT_ID = 2;
protected const ONE_TO_MANY_SELF_REFERENCING_PRODUCT_ID = 3;
@@ -44,20 +47,20 @@ class EntityExtensionTest extends TransactionFunctionalTestCase
protected const ORDER_ITEM_ID = 1;
/**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
+ * @var \Tests\App\Functional\EntityExtension\OverwritableEntityNameResolver
+ * @inject
*/
- private $em;
+ private $entityNameResolver;
/**
- * @var \Tests\App\Functional\EntityExtension\OverwritableEntityNameResolver
+ * @var \Tests\App\Functional\EntityExtension\OverwritableLoadORMMetadataSubscriber
* @inject
*/
- private $entityNameResolver;
+ private $loadORMMetadataSubscriber;
- public function setUp()
+ protected function setUp(): void
{
parent::setUp();
- $this->em = $this->getEntityManager();
$this->registerTestEntities();
$entityExtensionMap = [
@@ -69,7 +72,7 @@ public function setUp()
ProductTranslation::class => ExtendedProductTranslation::class,
];
- $applicationEntityExtensionMap = $this->getContainer()->getParameter('shopsys.entity_extension.map');
+ $applicationEntityExtensionMap = static::bootKernel()->getContainer()->getParameter('shopsys.entity_extension.map');
foreach ($applicationEntityExtensionMap as $baseClass => $extendedClass) {
if (!array_key_exists($baseClass, $entityExtensionMap)) {
@@ -114,10 +117,7 @@ public function registerTestEntities(): void
*/
public function overwriteEntityExtensionMapInServicesInContainer(array $entityExtensionMap): void
{
- /** @var \Tests\App\Functional\EntityExtension\OverwritableLoadORMMetadataSubscriber $loadORMMetadataSubscriber */
- $loadORMMetadataSubscriber = $this->getContainer()->get('joschi127_doctrine_entity_override.event_subscriber.load_orm_metadata');
-
- $loadORMMetadataSubscriber->overwriteEntityExtensionMap($entityExtensionMap);
+ $this->loadORMMetadataSubscriber->overwriteEntityExtensionMap($entityExtensionMap);
$this->entityNameResolver->overwriteEntityExtensionMap($entityExtensionMap);
}
diff --git a/tests/App/Functional/EntityExtension/Model/ExtendedCategory.php b/tests/App/Functional/EntityExtension/Model/ExtendedCategory.php
index 211b0abff3..0d2e6740b5 100644
--- a/tests/App/Functional/EntityExtension/Model/ExtendedCategory.php
+++ b/tests/App/Functional/EntityExtension/Model/ExtendedCategory.php
@@ -4,10 +4,10 @@
namespace Tests\App\Functional\EntityExtension\Model;
-use App\Model\Category\Category;
use App\Model\Category\CategoryData;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
+use Shopsys\FrameworkBundle\Model\Category\Category;
/**
* @ORM\Entity
diff --git a/tests/App/Functional/EntityExtension/Model/ExtendedProduct.php b/tests/App/Functional/EntityExtension/Model/ExtendedProduct.php
index d82e619f5f..792019db29 100644
--- a/tests/App/Functional/EntityExtension/Model/ExtendedProduct.php
+++ b/tests/App/Functional/EntityExtension/Model/ExtendedProduct.php
@@ -4,9 +4,9 @@
namespace Tests\App\Functional\EntityExtension\Model;
-use App\Model\Product\Product;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
+use Shopsys\FrameworkBundle\Model\Product\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductData;
/**
diff --git a/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOperatorTranslationTest.php b/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOperatorTranslationTest.php
index c63f21617f..e1a702df03 100644
--- a/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOperatorTranslationTest.php
+++ b/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOperatorTranslationTest.php
@@ -6,9 +6,12 @@
use Shopsys\FrameworkBundle\Form\Admin\AdvancedSearch\AdvancedSearchOperatorTranslation;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class AdvancedSearchOperatorTranslationTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\AdvancedSearch\ProductAdvancedSearchConfig
* @inject
diff --git a/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOrderFilterTranslationTest.php b/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOrderFilterTranslationTest.php
index eabbc50a04..3fc2b33ce9 100644
--- a/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOrderFilterTranslationTest.php
+++ b/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchOrderFilterTranslationTest.php
@@ -6,9 +6,12 @@
use Shopsys\FrameworkBundle\Form\Admin\AdvancedSearch\AdvancedSearchOrderFilterTranslation;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class AdvancedSearchOrderFilterTranslationTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\AdvancedSearch\OrderAdvancedSearchConfig
* @inject
diff --git a/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchProductFilterTranslationTest.php b/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchProductFilterTranslationTest.php
index 0c76c6c599..16f6bf634e 100644
--- a/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchProductFilterTranslationTest.php
+++ b/tests/App/Functional/Form/Admin/AdvancedSearch/AdvancedSearchProductFilterTranslationTest.php
@@ -6,9 +6,12 @@
use Shopsys\FrameworkBundle\Form\Admin\AdvancedSearch\AdvancedSearchProductFilterTranslation;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class AdvancedSearchProductFilterTranslationTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\AdvancedSearch\ProductAdvancedSearchConfig
* @inject
diff --git a/tests/App/Functional/Model/Administrator/AdministratorRepositoryTest.php b/tests/App/Functional/Model/Administrator/AdministratorRepositoryTest.php
index 32bde31375..9cd973eeaf 100644
--- a/tests/App/Functional/Model/Administrator/AdministratorRepositoryTest.php
+++ b/tests/App/Functional/Model/Administrator/AdministratorRepositoryTest.php
@@ -7,9 +7,12 @@
use App\DataFixtures\Demo\AdministratorDataFixture;
use DateTime;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class AdministratorRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Administrator\AdministratorRepository
* @inject
@@ -25,7 +28,7 @@ public function testGetByValidMultidomainLogin()
$administrator = $this->getReference(AdministratorDataFixture::ADMINISTRATOR);
$administrator->setMultidomainLoginTokenWithExpiration($validMultidomainLoginToken, $multidomainLoginTokenExpiration);
- $this->getEntityManager()->flush($administrator);
+ $this->em->flush($administrator);
$administratorFromDb = $this->administratorRepository->getByValidMultidomainLoginToken($validMultidomainLoginToken);
@@ -42,7 +45,7 @@ public function testGetByValidMultidomainLoginTokenInvalidTokenException()
$administrator = $this->getReference(AdministratorDataFixture::ADMINISTRATOR);
$administrator->setMultidomainLoginTokenWithExpiration($validMultidomainLoginToken, $multidomainLoginTokenExpiration);
- $this->getEntityManager()->flush($administrator);
+ $this->em->flush($administrator);
$this->expectException('\Shopsys\FrameworkBundle\Model\Administrator\Security\Exception\InvalidTokenException');
@@ -58,7 +61,7 @@ public function testGetByValidMultidomainLoginTokenExpiredTokenException()
$administrator = $this->getReference(AdministratorDataFixture::ADMINISTRATOR);
$administrator->setMultidomainLoginTokenWithExpiration($validMultidomainLoginToken, $multidomainLoginTokenExpiration);
- $this->getEntityManager()->flush($administrator);
+ $this->em->flush($administrator);
$this->expectException('\Shopsys\FrameworkBundle\Model\Administrator\Security\Exception\InvalidTokenException');
diff --git a/tests/App/Functional/Model/Administrator/Security/AdministratorFrontSecurityFacadeTest.php b/tests/App/Functional/Model/Administrator/Security/AdministratorFrontSecurityFacadeTest.php
index dba25f6684..7ed3190a52 100644
--- a/tests/App/Functional/Model/Administrator/Security/AdministratorFrontSecurityFacadeTest.php
+++ b/tests/App/Functional/Model/Administrator/Security/AdministratorFrontSecurityFacadeTest.php
@@ -8,9 +8,12 @@
use Shopsys\FrameworkBundle\Model\Administrator\Security\AdministratorFrontSecurityFacade;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class AdministratorFrontSecurityFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Administrator\Security\AdministratorFrontSecurityFacade
* @inject
@@ -23,6 +26,12 @@ class AdministratorFrontSecurityFacadeTest extends TransactionFunctionalTestCase
*/
private $administratorActivityFacade;
+ /**
+ * @var \Symfony\Component\HttpFoundation\Session\SessionInterface
+ * @inject
+ */
+ protected $session;
+
public function testIsAdministratorLoggedNot()
{
$this->assertFalse($this->administratorFrontSecurityFacade->isAdministratorLogged());
@@ -30,16 +39,13 @@ public function testIsAdministratorLoggedNot()
public function testIsAdministratorLogged()
{
- /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
- $session = $this->getContainer()->get('session');
-
/** @var \App\Model\Administrator\Administrator $administrator */
$administrator = $this->getReference(AdministratorDataFixture::ADMINISTRATOR);
$password = '';
$roles = $administrator->getRoles();
$token = new UsernamePasswordToken($administrator, $password, AdministratorFrontSecurityFacade::ADMINISTRATION_CONTEXT, $roles);
- $session->set('_security_' . AdministratorFrontSecurityFacade::ADMINISTRATION_CONTEXT, serialize($token));
+ $this->session->set('_security_' . AdministratorFrontSecurityFacade::ADMINISTRATION_CONTEXT, serialize($token));
$this->administratorActivityFacade->create($administrator, '127.0.0.1');
diff --git a/tests/App/Functional/Model/Article/ArticleTest.php b/tests/App/Functional/Model/Article/ArticleTest.php
index e227c80c94..16cc89f2c4 100644
--- a/tests/App/Functional/Model/Article/ArticleTest.php
+++ b/tests/App/Functional/Model/Article/ArticleTest.php
@@ -7,9 +7,12 @@
use App\Model\Article\Article;
use DateTime;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ArticleTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Article\ArticleDataFactoryInterface
* @inject
@@ -22,17 +25,6 @@ class ArticleTest extends TransactionFunctionalTestCase
*/
private $articleFactory;
- /**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
- */
- private $em;
-
- public function setUp()
- {
- parent::setUp();
- $this->em = $this->getEntityManager();
- }
-
public function testArticleIsCorrectlyRestoredFromDatabase()
{
/** @var \App\Model\Article\ArticleData $articleData */
diff --git a/tests/App/Functional/Model/Cart/CartFacadeDeleteOldCartsTest.php b/tests/App/Functional/Model/Cart/CartFacadeDeleteOldCartsTest.php
index 72709a5289..33157d5de6 100644
--- a/tests/App/Functional/Model/Cart/CartFacadeDeleteOldCartsTest.php
+++ b/tests/App/Functional/Model/Cart/CartFacadeDeleteOldCartsTest.php
@@ -11,9 +11,12 @@
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserIdentifier;
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserIdentifierFactory;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CartFacadeDeleteOldCartsTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Cart\CartFactory
* @inject
@@ -82,8 +85,7 @@ public function testOldUnregisteredCustomerCartGetsDeleted()
$cart->setModifiedAt(new DateTime('- 61 days'));
- $em = $this->getEntityManager();
- $em->flush($cart);
+ $this->em->flush($cart);
$cartFacade->deleteOldCarts();
@@ -98,8 +100,7 @@ public function testUnregisteredCustomerCartDoesNotGetDeleted()
$cart->setModifiedAt(new DateTime('- 59 days'));
- $em = $this->getEntityManager();
- $em->flush($cart);
+ $this->em->flush($cart);
$cartFacade->deleteOldCarts();
@@ -114,8 +115,7 @@ public function testOldRegisteredCustomerCartGetsDeleted()
$cart->setModifiedAt(new DateTime('- 121 days'));
- $em = $this->getEntityManager();
- $em->flush($cart);
+ $this->em->flush($cart);
$cartFacade->deleteOldCarts();
@@ -130,8 +130,7 @@ public function testRegisteredCustomerCartDoesNotGetDeletedIfItContainsRecentlyA
$cart->setModifiedAt(new DateTime('- 119 days'));
- $em = $this->getEntityManager();
- $em->flush($cart);
+ $this->em->flush($cart);
$cartFacade->deleteOldCarts();
@@ -174,7 +173,7 @@ private function getCartFacadeForUnregisteredCustomer()
private function getCartFacadeForCustomerUser(CustomerUserIdentifier $customerUserIdentifier)
{
return new CartFacade(
- $this->getEntityManager(),
+ $this->em,
$this->cartFactory,
$this->productRepository,
$this->getCustomerUserIdentifierFactoryMock($customerUserIdentifier),
@@ -252,15 +251,13 @@ private function getCustomerUserIdentifierForUnregisteredCustomer()
*/
private function createCartWithProduct(CustomerUserIdentifier $customerUserIdentifier, CartFacade $cartFacade)
{
- $em = $this->getEntityManager();
-
$product = $this->getProductById(1);
$cart = $cartFacade->getCartByCustomerUserIdentifierCreateIfNotExists($customerUserIdentifier);
$cartItem = new CartItem($cart, $product, 1, Money::zero());
- $em->persist($cartItem);
- $em->flush();
+ $this->em->persist($cartItem);
+ $this->em->flush();
$cart->addItem($cartItem);
diff --git a/tests/App/Functional/Model/Cart/CartFacadeTest.php b/tests/App/Functional/Model/Cart/CartFacadeTest.php
index f2d52c6616..b67daa41e9 100644
--- a/tests/App/Functional/Model/Cart/CartFacadeTest.php
+++ b/tests/App/Functional/Model/Cart/CartFacadeTest.php
@@ -10,9 +10,12 @@
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserIdentifier;
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserIdentifierFactory;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CartFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Localization\TranslatableListener
* @inject
@@ -210,8 +213,8 @@ public function testCartNotExistIfNoListableProductIsInCart(int $productId, bool
$cartItem = $this->cartItemFactory->create($cart, $product, 1, Money::create(10));
$cart->addItem($cartItem);
- $this->getEntityManager()->persist($cartItem);
- $this->getEntityManager()->flush();
+ $this->em->persist($cartItem);
+ $this->em->flush();
$this->assertFalse($cart->isEmpty(), 'Cart should not be empty');
@@ -241,7 +244,7 @@ public function productCartDataProvider()
private function createCartFacade(CustomerUserIdentifier $customerUserIdentifier)
{
return new CartFacade(
- $this->getEntityManager(),
+ $this->em,
$this->cartFactory,
$this->productRepository,
$this->getCustomerUserIdentifierFactoryMock($customerUserIdentifier),
diff --git a/tests/App/Functional/Model/Cart/CartItemTest.php b/tests/App/Functional/Model/Cart/CartItemTest.php
index 58097e0776..e27d8a5348 100644
--- a/tests/App/Functional/Model/Cart/CartItemTest.php
+++ b/tests/App/Functional/Model/Cart/CartItemTest.php
@@ -13,9 +13,12 @@
use Shopsys\FrameworkBundle\Model\Product\Availability\Availability;
use Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityData;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CartItemTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductDataFactoryInterface
* @inject
@@ -30,8 +33,6 @@ class CartItemTest extends TransactionFunctionalTestCase
public function testIsSimilarItemAs()
{
- $em = $this->getEntityManager();
-
$customerUserIdentifier = new CustomerUserIdentifier('randomString');
$availabilityData = new AvailabilityData();
@@ -51,10 +52,10 @@ public function testIsSimilarItemAs()
$product1 = Product::create($productData);
$product2 = Product::create($productData);
- $em->persist($availability);
- $em->persist($product1);
- $em->persist($product2);
- $em->flush();
+ $this->em->persist($availability);
+ $this->em->persist($product1);
+ $this->em->persist($product2);
+ $this->em->flush();
$cart = new Cart($customerUserIdentifier->getCartIdentifier());
diff --git a/tests/App/Functional/Model/Cart/CartMigrationFacadeTest.php b/tests/App/Functional/Model/Cart/CartMigrationFacadeTest.php
index cd840e3c02..c9d766d53c 100644
--- a/tests/App/Functional/Model/Cart/CartMigrationFacadeTest.php
+++ b/tests/App/Functional/Model/Cart/CartMigrationFacadeTest.php
@@ -16,9 +16,12 @@
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserIdentifier;
use Shopsys\FrameworkBundle\Model\Customer\User\CustomerUserIdentifierFactory;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CartMigrationFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Cart\Item\CartItemFactoryInterface
* @inject
diff --git a/tests/App/Functional/Model/Cart/CartTest.php b/tests/App/Functional/Model/Cart/CartTest.php
index 748ee52b26..0cf416b9a7 100644
--- a/tests/App/Functional/Model/Cart/CartTest.php
+++ b/tests/App/Functional/Model/Cart/CartTest.php
@@ -14,9 +14,12 @@
use Shopsys\FrameworkBundle\Model\Product\Availability\Availability;
use Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityData;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CartTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductDataFactoryInterface
* @inject
@@ -31,8 +34,6 @@ class CartTest extends TransactionFunctionalTestCase
public function testRemoveItem()
{
- $em = $this->getEntityManager();
-
$customerUserIdentifier = new CustomerUserIdentifier('randomString');
$availabilityData = new AvailabilityData();
@@ -54,17 +55,17 @@ public function testRemoveItem()
$cartItem2 = new CartItem($cart, $product2, 3, Money::zero());
$cart->addItem($cartItem2);
- $em->persist($cart);
- $em->persist($availability);
- $em->persist($product1);
- $em->persist($product2);
- $em->persist($cartItem1);
- $em->persist($cartItem2);
- $em->flush();
+ $this->em->persist($cart);
+ $this->em->persist($availability);
+ $this->em->persist($product1);
+ $this->em->persist($product2);
+ $this->em->persist($cartItem1);
+ $this->em->persist($cartItem2);
+ $this->em->flush();
$cart->removeItemById($cartItem1->getId());
- $em->remove($cartItem1);
- $em->flush();
+ $this->em->remove($cartItem1);
+ $this->em->flush();
$this->assertSame(1, $cart->getItemsCount());
}
diff --git a/tests/App/Functional/Model/Cart/Watcher/CartWatcherTest.php b/tests/App/Functional/Model/Cart/Watcher/CartWatcherTest.php
index aa725202c7..1efab637c3 100644
--- a/tests/App/Functional/Model/Cart/Watcher/CartWatcherTest.php
+++ b/tests/App/Functional/Model/Cart/Watcher/CartWatcherTest.php
@@ -18,9 +18,12 @@
use Shopsys\FrameworkBundle\Model\Product\ProductVisibility;
use Shopsys\FrameworkBundle\Model\Product\ProductVisibilityRepository;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CartWatcherTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Pricing\ProductPriceCalculationForCustomerUser
* @inject
diff --git a/tests/App/Functional/Model/Category/CategoryDomainTest.php b/tests/App/Functional/Model/Category/CategoryDomainTest.php
index ec0c3fe8e3..7d0aeb66fe 100644
--- a/tests/App/Functional/Model/Category/CategoryDomainTest.php
+++ b/tests/App/Functional/Model/Category/CategoryDomainTest.php
@@ -6,9 +6,12 @@
use App\Model\Category\Category;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CategoryDomainTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_ID = 1;
protected const SECOND_DOMAIN_ID = 2;
protected const DEMONSTRATIVE_SEO_TITLE = 'Demonstrative seo title';
@@ -27,17 +30,6 @@ class CategoryDomainTest extends TransactionFunctionalTestCase
*/
private $categoryFactory;
- /**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
- */
- private $em;
-
- public function setUp()
- {
- parent::setUp();
- $this->em = $this->getEntityManager();
- }
-
public function testCreateCategoryEnabledOnDomain()
{
$categoryData = $this->categoryDataFactory->create();
diff --git a/tests/App/Functional/Model/Category/CategoryRepositoryTest.php b/tests/App/Functional/Model/Category/CategoryRepositoryTest.php
index f2db122928..25773d0893 100644
--- a/tests/App/Functional/Model/Category/CategoryRepositoryTest.php
+++ b/tests/App/Functional/Model/Category/CategoryRepositoryTest.php
@@ -5,9 +5,12 @@
namespace Tests\App\Functional\Model\Category;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class CategoryRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_ID = 1;
protected const SECOND_DOMAIN_ID = 2;
diff --git a/tests/App/Functional/Model/Customer/UserFacadeTest.php b/tests/App/Functional/Model/Customer/UserFacadeTest.php
index dfb9bc2d5d..952b4daa1b 100644
--- a/tests/App/Functional/Model/Customer/UserFacadeTest.php
+++ b/tests/App/Functional/Model/Customer/UserFacadeTest.php
@@ -7,9 +7,12 @@
use App\DataFixtures\Demo\PricingGroupDataFixture;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class UserFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const EXISTING_EMAIL_ON_DOMAIN_1 = 'no-reply.3@shopsys.com';
protected const EXISTING_EMAIL_ON_DOMAIN_2 = 'no-reply.4@shopsys.com';
diff --git a/tests/App/Functional/Model/Newsletter/NewsletterRepository/GetAllEmailsDataIteratorMethodTest.php b/tests/App/Functional/Model/Newsletter/NewsletterRepository/GetAllEmailsDataIteratorMethodTest.php
index 8de3eaa608..bc64353296 100644
--- a/tests/App/Functional/Model/Newsletter/NewsletterRepository/GetAllEmailsDataIteratorMethodTest.php
+++ b/tests/App/Functional/Model/Newsletter/NewsletterRepository/GetAllEmailsDataIteratorMethodTest.php
@@ -8,9 +8,12 @@
use PHPUnit\Framework\Assert;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class GetAllEmailsDataIteratorMethodTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_SUBSCRIBER_EMAIL = 'james.black@no-reply.com';
/**
diff --git a/tests/App/Functional/Model/Newsletter/Subscriber/NewsletterSubscriberPersistenceTest.php b/tests/App/Functional/Model/Newsletter/Subscriber/NewsletterSubscriberPersistenceTest.php
index 8dc53dc59e..574f940484 100644
--- a/tests/App/Functional/Model/Newsletter/Subscriber/NewsletterSubscriberPersistenceTest.php
+++ b/tests/App/Functional/Model/Newsletter/Subscriber/NewsletterSubscriberPersistenceTest.php
@@ -20,12 +20,11 @@ public function testPersistence(): void
1
);
- $em = $this->getEntityManager();
- $em->persist($newsletterSubscriber);
- $em->flush();
- $em->clear();
+ $this->em->persist($newsletterSubscriber);
+ $this->em->flush();
+ $this->em->clear();
- $found = $em->createQueryBuilder()
+ $found = $this->em->createQueryBuilder()
->select('ns')
->from(NewsletterSubscriber::class, 'ns')
->where('ns.email = :email')
diff --git a/tests/App/Functional/Model/Order/Mail/OrderMailTest.php b/tests/App/Functional/Model/Order/Mail/OrderMailTest.php
index 8c51bd62da..b5f3f2dc77 100644
--- a/tests/App/Functional/Model/Order/Mail/OrderMailTest.php
+++ b/tests/App/Functional/Model/Order/Mail/OrderMailTest.php
@@ -19,7 +19,7 @@
use Shopsys\FrameworkBundle\Twig\PriceExtension;
use Symfony\Component\Routing\RouterInterface;
use Tests\App\Test\FunctionalTestCase;
-use Twig_Environment;
+use Twig\Environment;
class OrderMailTest extends FunctionalTestCase
{
@@ -41,10 +41,10 @@ public function testGetMailTemplateNameByStatus()
$mailTempleteName2 = OrderMail::getMailTemplateNameByStatus($orderStatus2);
$this->assertNotEmpty($mailTempleteName1);
- $this->assertInternalType('string', $mailTempleteName1);
+ $this->assertIsString($mailTempleteName1);
$this->assertNotEmpty($mailTempleteName2);
- $this->assertInternalType('string', $mailTempleteName2);
+ $this->assertIsString($mailTempleteName2);
$this->assertNotSame($mailTempleteName1, $mailTempleteName2);
}
@@ -60,7 +60,7 @@ public function testGetMessageByOrder()
->getMock();
$domainRouterFactoryMock->expects($this->any())->method('getRouter')->willReturn($routerMock);
- $twigMock = $this->getMockBuilder(Twig_Environment::class)->disableOriginalConstructor()->getMock();
+ $twigMock = $this->getMockBuilder(Environment::class)->disableOriginalConstructor()->getMock();
$orderItemPriceCalculationMock = $this->getMockBuilder(OrderItemPriceCalculation::class)->disableOriginalConstructor()->getMock();
$settingMock = $this->getMockBuilder(Setting::class)->disableOriginalConstructor()->getMock();
$priceExtensionMock = $this->getMockBuilder(PriceExtension::class)->disableOriginalConstructor()->getMock();
diff --git a/tests/App/Functional/Model/Order/OrderFacadeEditTest.php b/tests/App/Functional/Model/Order/OrderFacadeEditTest.php
index b6a89c5344..68888b4b62 100644
--- a/tests/App/Functional/Model/Order/OrderFacadeEditTest.php
+++ b/tests/App/Functional/Model/Order/OrderFacadeEditTest.php
@@ -11,9 +11,12 @@
use Shopsys\FrameworkBundle\Model\Order\OrderData;
use Tests\App\Test\TransactionFunctionalTestCase;
use Tests\FrameworkBundle\Test\IsMoneyEqual;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
final class OrderFacadeEditTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
private const ORDER_ID = 10;
private const PRODUCT_ITEM_ID = 45;
private const PAYMENT_ITEM_ID = 46;
diff --git a/tests/App/Functional/Model/Order/OrderFacadeTest.php b/tests/App/Functional/Model/Order/OrderFacadeTest.php
index 914b034d71..f146bda172 100644
--- a/tests/App/Functional/Model/Order/OrderFacadeTest.php
+++ b/tests/App/Functional/Model/Order/OrderFacadeTest.php
@@ -12,9 +12,12 @@
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Component\Money\Money;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class OrderFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Cart\CartFacade
* @inject
@@ -57,12 +60,6 @@ class OrderFacadeTest extends TransactionFunctionalTestCase
*/
private $paymentRepository;
- /**
- * @var \Shopsys\FrameworkBundle\Component\DataFixture\PersistentReferenceFacade
- * @inject
- */
- private $persistentReferenceFacade;
-
/**
* @var \Shopsys\FrameworkBundle\Model\Order\OrderDataFactoryInterface
* @inject
@@ -83,7 +80,7 @@ public function testCreate()
$orderData = new OrderData();
$orderData->transport = $transport;
$orderData->payment = $payment;
- $orderData->status = $this->persistentReferenceFacade->getReference(OrderStatusDataFixture::ORDER_STATUS_NEW);
+ $orderData->status = $this->getReference(OrderStatusDataFixture::ORDER_STATUS_NEW);
$orderData->firstName = 'firstName';
$orderData->lastName = 'lastName';
$orderData->email = 'email';
@@ -94,7 +91,7 @@ public function testCreate()
$orderData->street = 'street';
$orderData->city = 'city';
$orderData->postcode = 'postcode';
- $orderData->country = $this->persistentReferenceFacade->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
+ $orderData->country = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->deliveryAddressSameAsBillingAddress = false;
$orderData->deliveryFirstName = 'deliveryFirstName';
$orderData->deliveryLastName = 'deliveryLastName';
@@ -103,7 +100,7 @@ public function testCreate()
$orderData->deliveryStreet = 'deliveryStreet';
$orderData->deliveryCity = 'deliveryCity';
$orderData->deliveryPostcode = 'deliveryPostcode';
- $orderData->deliveryCountry = $this->persistentReferenceFacade->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
+ $orderData->deliveryCountry = $this->getReference(CountryDataFixture::COUNTRY_CZECH_REPUBLIC);
$orderData->note = 'note';
$orderData->domainId = Domain::FIRST_DOMAIN_ID;
$orderData->currency = $this->getReference(CurrencyDataFixture::CURRENCY_CZK);
diff --git a/tests/App/Functional/Model/Order/OrderNumberSequenceRepositoryTest.php b/tests/App/Functional/Model/Order/OrderNumberSequenceRepositoryTest.php
index 7a110038c9..2c1ab2a0ba 100644
--- a/tests/App/Functional/Model/Order/OrderNumberSequenceRepositoryTest.php
+++ b/tests/App/Functional/Model/Order/OrderNumberSequenceRepositoryTest.php
@@ -5,9 +5,12 @@
namespace Tests\App\Functional\Model\Order;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class OrderNumberSequenceRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Order\OrderNumberSequenceRepository
* @inject
diff --git a/tests/App/Functional/Model/Order/OrderTransportAndPaymentTest.php b/tests/App/Functional/Model/Order/OrderTransportAndPaymentTest.php
index 3c6aa28db3..8e2c5722dd 100644
--- a/tests/App/Functional/Model/Order/OrderTransportAndPaymentTest.php
+++ b/tests/App/Functional/Model/Order/OrderTransportAndPaymentTest.php
@@ -8,9 +8,12 @@
use App\Model\Transport\Transport;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class OrderTransportAndPaymentTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Transport\TransportFacade
* @inject
@@ -37,8 +40,6 @@ class OrderTransportAndPaymentTest extends TransactionFunctionalTestCase
public function testVisibleTransport()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
Domain::FIRST_DOMAIN_ID => true,
Domain::SECOND_DOMAIN_ID => false,
@@ -48,10 +49,10 @@ public function testVisibleTransport()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->flush();
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->flush();
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
$visibleTransports = $this->transportFacade->getVisibleOnCurrentDomain($visiblePayments);
@@ -61,8 +62,6 @@ public function testVisibleTransport()
public function testVisibleTransportHiddenTransport()
{
- $em = $this->getEntityManager();
-
$enabledOnDomains = [
1 => true,
2 => false,
@@ -72,9 +71,9 @@ public function testVisibleTransportHiddenTransport()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
$visibleTransports = $this->transportFacade->getVisibleOnCurrentDomain($visiblePayments);
@@ -84,8 +83,6 @@ public function testVisibleTransportHiddenTransport()
public function testVisibleTransportHiddenPayment()
{
- $em = $this->getEntityManager();
-
$transportEnabledForDomains = [
1 => true,
2 => false,
@@ -100,9 +97,9 @@ public function testVisibleTransportHiddenPayment()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
$visibleTransports = $this->transportFacade->getVisibleOnCurrentDomain($visiblePayments);
@@ -112,16 +109,14 @@ public function testVisibleTransportHiddenPayment()
public function testVisibleTransportNoPayment()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
1 => true,
2 => false,
];
$transport = $this->getDefaultTransport($enabledForDomains, false);
- $em->persist($transport);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
$visibleTransports = $this->transportFacade->getVisibleOnCurrentDomain($visiblePayments);
@@ -131,8 +126,6 @@ public function testVisibleTransportNoPayment()
public function testVisibleTransportOnDifferentDomain()
{
- $em = $this->getEntityManager();
-
$paymentEnabledForDomains = [
1 => true,
2 => false,
@@ -147,9 +140,9 @@ public function testVisibleTransportOnDifferentDomain()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
$visibleTransports = $this->transportFacade->getVisibleOnCurrentDomain($visiblePayments);
@@ -159,8 +152,6 @@ public function testVisibleTransportOnDifferentDomain()
public function testVisibleTransportPaymentOnDifferentDomain()
{
- $em = $this->getEntityManager();
-
$paymentEnabledForDomains = [
1 => false,
2 => true,
@@ -173,9 +164,9 @@ public function testVisibleTransportPaymentOnDifferentDomain()
$payment = $this->getDefaultPayment($paymentEnabledForDomains, false);
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
$visibleTransports = $this->transportFacade->getVisibleOnCurrentDomain($visiblePayments);
@@ -185,8 +176,6 @@ public function testVisibleTransportPaymentOnDifferentDomain()
public function testVisiblePayment()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
1 => true,
2 => false,
@@ -196,9 +185,9 @@ public function testVisiblePayment()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
@@ -207,8 +196,6 @@ public function testVisiblePayment()
public function testVisiblePaymentHiddenTransport()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
1 => true,
2 => false,
@@ -218,9 +205,9 @@ public function testVisiblePaymentHiddenTransport()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
@@ -229,8 +216,6 @@ public function testVisiblePaymentHiddenTransport()
public function testVisiblePaymentHiddenPayment()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
1 => true,
2 => false,
@@ -240,9 +225,9 @@ public function testVisiblePaymentHiddenPayment()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
@@ -251,16 +236,14 @@ public function testVisiblePaymentHiddenPayment()
public function testVisiblePaymentNoTransport()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
1 => true,
2 => false,
];
$payment = $this->getDefaultPayment($enabledForDomains, false);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
@@ -269,8 +252,6 @@ public function testVisiblePaymentNoTransport()
public function testVisiblePaymentOnDifferentDomain()
{
- $em = $this->getEntityManager();
-
$transportEnabledForDomains = [
1 => true,
2 => false,
@@ -283,9 +264,9 @@ public function testVisiblePaymentOnDifferentDomain()
$payment = $this->getDefaultPayment($paymentEnabledForDomains, false);
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
@@ -294,8 +275,6 @@ public function testVisiblePaymentOnDifferentDomain()
public function testVisiblePaymentTransportOnDifferentDomain()
{
- $em = $this->getEntityManager();
-
$transportEnabledForDomains = [
1 => true,
2 => false,
@@ -309,9 +288,9 @@ public function testVisiblePaymentTransportOnDifferentDomain()
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$visiblePayments = $this->paymentFacade->getVisibleOnCurrentDomain();
diff --git a/tests/App/Functional/Model/Order/Status/OrderStatusFacadeTest.php b/tests/App/Functional/Model/Order/Status/OrderStatusFacadeTest.php
index 2eed1cbef1..e30a3ebee0 100644
--- a/tests/App/Functional/Model/Order/Status/OrderStatusFacadeTest.php
+++ b/tests/App/Functional/Model/Order/Status/OrderStatusFacadeTest.php
@@ -8,9 +8,12 @@
use App\DataFixtures\Demo\OrderStatusDataFixture;
use Shopsys\FrameworkBundle\Model\Order\Status\OrderStatusData;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class OrderStatusFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Order\Status\OrderStatusFacade
* @inject
@@ -31,8 +34,6 @@ class OrderStatusFacadeTest extends TransactionFunctionalTestCase
public function testDeleteByIdAndReplace()
{
- $em = $this->getEntityManager();
-
$orderStatusData = new OrderStatusData();
$orderStatusData->name = ['cs' => 'name'];
$orderStatusToDelete = $this->orderStatusFacade->create($orderStatusData);
@@ -47,7 +48,7 @@ public function testDeleteByIdAndReplace()
$this->orderStatusFacade->deleteById($orderStatusToDelete->getId(), $orderStatusToReplaceWith->getId());
- $em->refresh($order);
+ $this->em->refresh($order);
$this->assertEquals($orderStatusToReplaceWith, $order->getStatus());
}
diff --git a/tests/App/Functional/Model/Payment/IndependentPaymentVisibilityCalculationTest.php b/tests/App/Functional/Model/Payment/IndependentPaymentVisibilityCalculationTest.php
index a4b306eb62..a96c505dd0 100644
--- a/tests/App/Functional/Model/Payment/IndependentPaymentVisibilityCalculationTest.php
+++ b/tests/App/Functional/Model/Payment/IndependentPaymentVisibilityCalculationTest.php
@@ -6,9 +6,12 @@
use App\Model\Payment\Payment;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class IndependentPaymentVisibilityCalculationTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_ID = 1;
protected const SECOND_DOMAIN_ID = 2;
@@ -32,24 +35,20 @@ class IndependentPaymentVisibilityCalculationTest extends TransactionFunctionalT
public function testIsIndependentlyVisible()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
self::FIRST_DOMAIN_ID => true,
self::SECOND_DOMAIN_ID => true,
];
$payment = $this->getDefaultPayment($enabledForDomains, false);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($payment);
+ $this->em->flush();
$this->assertTrue($this->independentPaymentVisibilityCalculation->isIndependentlyVisible($payment, self::FIRST_DOMAIN_ID));
}
public function testIsIndependentlyVisibleEmptyName()
{
- $em = $this->getEntityManager();
-
$paymentData = $this->paymentDataFactory->create();
$names = [];
foreach ($this->localization->getLocalesOfAllDomains() as $locale) {
@@ -64,40 +63,36 @@ public function testIsIndependentlyVisibleEmptyName()
$payment = new Payment($paymentData);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($payment);
+ $this->em->flush();
$this->assertFalse($this->independentPaymentVisibilityCalculation->isIndependentlyVisible($payment, self::FIRST_DOMAIN_ID));
}
public function testIsIndependentlyVisibleNotOnDomain()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
self::FIRST_DOMAIN_ID => false,
self::SECOND_DOMAIN_ID => false,
];
$payment = $this->getDefaultPayment($enabledForDomains, false);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($payment);
+ $this->em->flush();
$this->assertFalse($this->independentPaymentVisibilityCalculation->isIndependentlyVisible($payment, self::FIRST_DOMAIN_ID));
}
public function testIsIndependentlyVisibleHidden()
{
- $em = $this->getEntityManager();
-
$enabledForDomains = [
self::FIRST_DOMAIN_ID => false,
self::SECOND_DOMAIN_ID => false,
];
$payment = $this->getDefaultPayment($enabledForDomains, false);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($payment);
+ $this->em->flush();
$this->assertFalse($this->independentPaymentVisibilityCalculation->isIndependentlyVisible($payment, self::FIRST_DOMAIN_ID));
}
diff --git a/tests/App/Functional/Model/Payment/PaymentDomainTest.php b/tests/App/Functional/Model/Payment/PaymentDomainTest.php
index f351172540..bc911532af 100644
--- a/tests/App/Functional/Model/Payment/PaymentDomainTest.php
+++ b/tests/App/Functional/Model/Payment/PaymentDomainTest.php
@@ -6,9 +6,12 @@
use App\Model\Payment\Payment;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class PaymentDomainTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_ID = 1;
protected const SECOND_DOMAIN_ID = 2;
@@ -24,17 +27,6 @@ class PaymentDomainTest extends TransactionFunctionalTestCase
*/
private $paymentFactory;
- /**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
- */
- private $em;
-
- public function setUp()
- {
- parent::setUp();
- $this->em = $this->getEntityManager();
- }
-
public function testCreatePaymentEnabledOnDomain()
{
$paymentData = $this->paymentDataFactory->create();
diff --git a/tests/App/Functional/Model/Payment/PaymentTest.php b/tests/App/Functional/Model/Payment/PaymentTest.php
index 25cc758aa8..de15cbefb5 100644
--- a/tests/App/Functional/Model/Payment/PaymentTest.php
+++ b/tests/App/Functional/Model/Payment/PaymentTest.php
@@ -7,9 +7,12 @@
use App\Model\Payment\Payment;
use App\Model\Transport\Transport;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class PaymentTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Payment\PaymentDataFactoryInterface
* @inject
@@ -30,8 +33,6 @@ class PaymentTest extends TransactionFunctionalTestCase
public function testRemoveTransportFromPaymentAfterDelete()
{
- $em = $this->getEntityManager();
-
$transportData = $this->transportDataFactory->create();
$transportData->name['cs'] = 'name';
$transport = new Transport($transportData);
@@ -42,9 +43,9 @@ public function testRemoveTransportFromPaymentAfterDelete()
$payment = new Payment($paymentData);
$payment->addTransport($transport);
- $em->persist($transport);
- $em->persist($payment);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->persist($payment);
+ $this->em->flush();
$this->transportFacade->deleteById($transport->getId());
diff --git a/tests/App/Functional/Model/Pricing/Group/PricingGroupFacadeTest.php b/tests/App/Functional/Model/Pricing/Group/PricingGroupFacadeTest.php
index e109d6dc84..46534c7771 100644
--- a/tests/App/Functional/Model/Pricing/Group/PricingGroupFacadeTest.php
+++ b/tests/App/Functional/Model/Pricing/Group/PricingGroupFacadeTest.php
@@ -10,9 +10,12 @@
use Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroupData;
use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductCalculatedPrice;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class PricingGroupFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroupFacade
* @inject
@@ -45,7 +48,6 @@ class PricingGroupFacadeTest extends TransactionFunctionalTestCase
public function testCreate()
{
- $em = $this->getEntityManager();
/** @var \App\Model\Product\Product $product */
$product = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . '1');
@@ -54,7 +56,7 @@ public function testCreate()
$domainId = Domain::FIRST_DOMAIN_ID;
$pricingGroup = $this->pricingGroupFacade->create($pricingGroupData, $domainId);
$this->productPriceRecalculator->runAllScheduledRecalculations();
- $productCalculatedPrice = $em->getRepository(ProductCalculatedPrice::class)->findOneBy([
+ $productCalculatedPrice = $this->em->getRepository(ProductCalculatedPrice::class)->findOneBy([
'product' => $product,
'pricingGroup' => $pricingGroup,
]);
@@ -64,8 +66,6 @@ public function testCreate()
public function testDeleteAndReplace()
{
- $em = $this->getEntityManager();
-
$pricingGroupData = new PricingGroupData();
$pricingGroupData->name = 'name';
$pricingGroupToDelete = $this->pricingGroupFacade->create($pricingGroupData, Domain::FIRST_DOMAIN_ID);
@@ -82,7 +82,7 @@ public function testDeleteAndReplace()
$this->pricingGroupFacade->delete($pricingGroupToDelete->getId(), $pricingGroupToReplaceWith->getId());
- $em->refresh($customerUser);
+ $this->em->refresh($customerUser);
$this->assertEquals($pricingGroupToReplaceWith, $customerUser->getPricingGroup());
}
diff --git a/tests/App/Functional/Model/Pricing/InputPriceRecalculationSchedulerTest.php b/tests/App/Functional/Model/Pricing/InputPriceRecalculationSchedulerTest.php
index 401a835547..23ec69cd71 100644
--- a/tests/App/Functional/Model/Pricing/InputPriceRecalculationSchedulerTest.php
+++ b/tests/App/Functional/Model/Pricing/InputPriceRecalculationSchedulerTest.php
@@ -16,9 +16,12 @@
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Tests\App\Test\TransactionFunctionalTestCase;
use Tests\FrameworkBundle\Test\IsMoneyEqual;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class InputPriceRecalculationSchedulerTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
private const METHOD_WITH_VAT = 'scheduleSetInputPricesWithVat';
private const METHOD_WITHOUT_VAT = 'scheduleSetInputPricesWithoutVat';
@@ -135,8 +138,6 @@ public function testOnKernelResponseRecalculateInputPricesWithVat(
*/
private function doTestOnKernelResponseRecalculateInputPrices(Money $inputPrice, Money $expectedPrice, $vatPercent, string $scheduleSetInputPricesMethod): void
{
- $em = $this->getEntityManager();
-
$paymentData = $this->paymentDataFactory->create();
$transportData = $this->transportDataFactory->create();
@@ -150,8 +151,8 @@ private function doTestOnKernelResponseRecalculateInputPrices(Money $inputPrice,
$availabilityData = new AvailabilityData();
$availabilityData->dispatchTime = 0;
$availability = new Availability($availabilityData);
- $em->persist($vat);
- $em->persist($availability);
+ $this->em->persist($vat);
+ $this->em->persist($availability);
$paymentData->name = ['cs' => 'name'];
@@ -163,7 +164,7 @@ private function doTestOnKernelResponseRecalculateInputPrices(Money $inputPrice,
/** @var \App\Model\Transport\Transport $transport */
$transport = $this->transportFacade->create($transportData);
- $em->flush();
+ $this->em->flush();
$filterResponseEventMock = $this->getMockBuilder(FilterResponseEvent::class)
->disableOriginalConstructor()
@@ -180,8 +181,8 @@ private function doTestOnKernelResponseRecalculateInputPrices(Money $inputPrice,
$this->inputPriceRecalculationScheduler->onKernelResponse($filterResponseEventMock);
- $em->refresh($payment);
- $em->refresh($transport);
+ $this->em->refresh($payment);
+ $this->em->refresh($transport);
$this->assertThat($payment->getPrice(Domain::FIRST_DOMAIN_ID)->getPrice(), new IsMoneyEqual($expectedPrice));
$this->assertThat($transport->getPrice(Domain::FIRST_DOMAIN_ID)->getPrice(), new IsMoneyEqual($expectedPrice));
diff --git a/tests/App/Functional/Model/Pricing/ProductInputPriceRecalculatorTest.php b/tests/App/Functional/Model/Pricing/ProductInputPriceRecalculatorTest.php
index 5d48bf5333..1e06202d12 100644
--- a/tests/App/Functional/Model/Pricing/ProductInputPriceRecalculatorTest.php
+++ b/tests/App/Functional/Model/Pricing/ProductInputPriceRecalculatorTest.php
@@ -14,9 +14,12 @@
use Shopsys\FrameworkBundle\Model\Product\Pricing\ProductManualInputPrice;
use Tests\App\Test\TransactionFunctionalTestCase;
use Tests\FrameworkBundle\Test\IsMoneyEqual;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductInputPriceRecalculatorTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Component\Setting\Setting
* @inject
diff --git a/tests/App/Functional/Model/Product/Availability/AvailabilityFacadeTest.php b/tests/App/Functional/Model/Product/Availability/AvailabilityFacadeTest.php
index b7f7572c3c..ffa4826b4a 100644
--- a/tests/App/Functional/Model/Product/Availability/AvailabilityFacadeTest.php
+++ b/tests/App/Functional/Model/Product/Availability/AvailabilityFacadeTest.php
@@ -8,13 +8,11 @@
use Shopsys\FrameworkBundle\Model\Product\Availability\Availability;
use Shopsys\FrameworkBundle\Model\Product\Product;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
final class AvailabilityFacadeTest extends TransactionFunctionalTestCase
{
- /**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
- */
- private $em;
+ use SymfonyTestContainer;
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Availability\AvailabilityDataFactoryInterface
@@ -40,12 +38,6 @@ final class AvailabilityFacadeTest extends TransactionFunctionalTestCase
*/
private $productFacade;
- protected function setUp(): void
- {
- parent::setUp();
- $this->em = $this->getEntityManager();
- }
-
public function testDeleteByIdAndReplaceProductAvailability(): void
{
/** @var \App\Model\Product\Product $product */
diff --git a/tests/App/Functional/Model/Product/Availability/ProductAvailabilityCalculationTest.php b/tests/App/Functional/Model/Product/Availability/ProductAvailabilityCalculationTest.php
index fe1a8e0906..0a029104fa 100644
--- a/tests/App/Functional/Model/Product/Availability/ProductAvailabilityCalculationTest.php
+++ b/tests/App/Functional/Model/Product/Availability/ProductAvailabilityCalculationTest.php
@@ -15,9 +15,12 @@
use Shopsys\FrameworkBundle\Model\Product\ProductSellingDeniedRecalculator;
use Shopsys\FrameworkBundle\Model\Product\ProductVisibilityFacade;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductAvailabilityCalculationTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductDataFactoryInterface
* @inject
@@ -35,36 +38,43 @@ class ProductAvailabilityCalculationTest extends FunctionalTestCase
* @param mixed $usingStock
* @param mixed $stockQuantity
* @param mixed $outOfStockAction
- * @param \Shopsys\FrameworkBundle\Model\Product\Availability\Availability|null $availability
- * @param \Shopsys\FrameworkBundle\Model\Product\Availability\Availability|null $outOfStockAvailability
- * @param \Shopsys\FrameworkBundle\Model\Product\Availability\Availability|null $defaultInStockAvailability
- * @param \Shopsys\FrameworkBundle\Model\Product\Availability\Availability|null $expectedCalculatedAvailability
+ * @param string|null $availability
+ * @param string|null $outOfStockAvailability
+ * @param string|null $defaultInStockAvailability
+ * @param string|null $expectedCalculatedAvailability
*/
public function testCalculateAvailability(
$usingStock,
$stockQuantity,
$outOfStockAction,
- ?Availability $availability = null,
- ?Availability $outOfStockAvailability = null,
- ?Availability $defaultInStockAvailability = null,
- ?Availability $expectedCalculatedAvailability = null
+ ?string $availability = null,
+ ?string $outOfStockAvailability = null,
+ ?string $defaultInStockAvailability = null,
+ ?string $expectedCalculatedAvailability = null
) {
$productData = $this->productDataFactory->create();
$productData->usingStock = $usingStock;
$productData->stockQuantity = $stockQuantity;
- $productData->availability = $availability;
+
+ if ($availability !== null) {
+ $productData->availability = $this->getReference($availability);
+ }
+
$productData->outOfStockAction = $outOfStockAction;
- $productData->outOfStockAvailability = $outOfStockAvailability;
+
+ if ($outOfStockAvailability !== null) {
+ $productData->outOfStockAvailability = $this->getReference($outOfStockAvailability);
+ }
+
$this->setVats($productData);
$product = Product::create($productData);
$availabilityFacadeMock = $this->getMockBuilder(AvailabilityFacade::class)
- ->setMethods(['getDefaultInStockAvailability'])
->disableOriginalConstructor()
->getMock();
$availabilityFacadeMock->expects($this->any())->method('getDefaultInStockAvailability')
- ->willReturn($defaultInStockAvailability);
+ ->willReturn($this->getReference($defaultInStockAvailability));
$productSellingDeniedRecalculatorMock = $this->createMock(ProductSellingDeniedRecalculator::class);
$productVisibilityFacadeMock = $this->createMock(ProductVisibilityFacade::class);
@@ -81,7 +91,7 @@ public function testCalculateAvailability(
$calculatedAvailability = $productAvailabilityCalculation->calculateAvailability($product);
- $this->assertSame($expectedCalculatedAvailability, $calculatedAvailability);
+ $this->assertSame($this->getReference($expectedCalculatedAvailability), $calculatedAvailability);
}
public function getTestCalculateAvailabilityData()
@@ -91,46 +101,46 @@ public function getTestCalculateAvailabilityData()
'usingStock' => false,
'stockQuantity' => null,
'outOfStockAction' => null,
- 'availability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
+ 'availability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
'outOfStockAvailability' => null,
- 'defaultInStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
- 'calculatedAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
+ 'defaultInStockAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
+ 'calculatedAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
],
[
'usingStock' => true,
'stockQuantity' => null,
'outOfStockAction' => Product::OUT_OF_STOCK_ACTION_HIDE,
- 'availability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
+ 'availability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
'outOfStockAvailability' => null,
- 'defaultInStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
- 'calculatedAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
+ 'defaultInStockAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
+ 'calculatedAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
],
[
'usingStock' => true,
'stockQuantity' => 5,
'outOfStockAction' => Product::OUT_OF_STOCK_ACTION_SET_ALTERNATE_AVAILABILITY,
'availability' => null,
- 'outOfStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK),
- 'defaultInStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
- 'calculatedAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
+ 'outOfStockAvailability' => AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK,
+ 'defaultInStockAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
+ 'calculatedAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
],
[
'usingStock' => true,
'stockQuantity' => 0,
'outOfStockAction' => Product::OUT_OF_STOCK_ACTION_SET_ALTERNATE_AVAILABILITY,
'availability' => null,
- 'outOfStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK),
- 'defaultInStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
- 'calculatedAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK),
+ 'outOfStockAvailability' => AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK,
+ 'defaultInStockAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
+ 'calculatedAvailability' => AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK,
],
[
'usingStock' => true,
'stockQuantity' => -1,
'outOfStockAction' => Product::OUT_OF_STOCK_ACTION_SET_ALTERNATE_AVAILABILITY,
'availability' => null,
- 'outOfStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK),
- 'defaultInStockAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_IN_STOCK),
- 'calculatedAvailability' => $this->getReference(AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK),
+ 'outOfStockAvailability' => AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK,
+ 'defaultInStockAvailability' => AvailabilityDataFixture::AVAILABILITY_IN_STOCK,
+ 'calculatedAvailability' => AvailabilityDataFixture::AVAILABILITY_OUT_OF_STOCK,
],
];
}
diff --git a/tests/App/Functional/Model/Product/Availability/ProductAvailabilityRecalculatorTest.php b/tests/App/Functional/Model/Product/Availability/ProductAvailabilityRecalculatorTest.php
index 143b6d7651..efff3df42b 100644
--- a/tests/App/Functional/Model/Product/Availability/ProductAvailabilityRecalculatorTest.php
+++ b/tests/App/Functional/Model/Product/Availability/ProductAvailabilityRecalculatorTest.php
@@ -7,9 +7,12 @@
use App\DataFixtures\Demo\AvailabilityDataFixture;
use App\Model\Product\Product;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductAvailabilityRecalculatorTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductFacade
* @inject
@@ -46,8 +49,8 @@ public function testRecalculateOnProductEditNotUsingStock()
$this->productFacade->edit($productId, $productData);
$this->productAvailabilityRecalculator->runAllScheduledRecalculations();
- $this->getEntityManager()->flush();
- $this->getEntityManager()->clear();
+ $this->em->flush();
+ $this->em->clear();
$productFromDb = $this->productFacade->getById($productId);
@@ -68,8 +71,8 @@ public function testRecalculateOnProductEditUsingStockInStock()
$this->productFacade->edit($productId, $productData);
$this->productAvailabilityRecalculator->runAllScheduledRecalculations();
- $this->getEntityManager()->flush();
- $this->getEntityManager()->clear();
+ $this->em->flush();
+ $this->em->clear();
$productFromDb = $this->productFacade->getById($productId);
@@ -91,8 +94,8 @@ public function testRecalculateOnProductEditUsingStockOutOfStock()
$this->productFacade->edit($productId, $productData);
$this->productAvailabilityRecalculator->runAllScheduledRecalculations();
- $this->getEntityManager()->flush();
- $this->getEntityManager()->clear();
+ $this->em->flush();
+ $this->em->clear();
$productFromDb = $this->productFacade->getById($productId);
diff --git a/tests/App/Functional/Model/Product/Brand/BrandDomainTest.php b/tests/App/Functional/Model/Product/Brand/BrandDomainTest.php
index a6ea494d5f..c28a8cf05d 100644
--- a/tests/App/Functional/Model/Product/Brand/BrandDomainTest.php
+++ b/tests/App/Functional/Model/Product/Brand/BrandDomainTest.php
@@ -6,9 +6,12 @@
use App\Model\Product\Brand\Brand;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class BrandDomainTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_ID = 1;
protected const SECOND_DOMAIN_ID = 2;
protected const DEMONSTRATIVE_SEO_TITLE = 'Demonstrative seo title';
@@ -26,17 +29,6 @@ class BrandDomainTest extends TransactionFunctionalTestCase
*/
private $brandFactory;
- /**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
- */
- private $em;
-
- public function setUp()
- {
- parent::setUp();
- $this->em = $this->getEntityManager();
- }
-
/**
* @group multidomain
*/
diff --git a/tests/App/Functional/Model/Product/Elasticsearch/ProductExportRepositoryTest.php b/tests/App/Functional/Model/Product/Elasticsearch/ProductExportRepositoryTest.php
index 32bb5bcb58..1bf8c51ac4 100644
--- a/tests/App/Functional/Model/Product/Elasticsearch/ProductExportRepositoryTest.php
+++ b/tests/App/Functional/Model/Product/Elasticsearch/ProductExportRepositoryTest.php
@@ -5,9 +5,12 @@
namespace Tests\App\Functional\Model\Product\Elasticsearch;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductExportRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Elasticsearch\ProductExportRepository
* @inject
diff --git a/tests/App/Functional/Model/Product/Filter/BrandFilterChoiceRepositoryTest.php b/tests/App/Functional/Model/Product/Filter/BrandFilterChoiceRepositoryTest.php
index dd13e950da..fca9b82a86 100644
--- a/tests/App/Functional/Model/Product/Filter/BrandFilterChoiceRepositoryTest.php
+++ b/tests/App/Functional/Model/Product/Filter/BrandFilterChoiceRepositoryTest.php
@@ -9,9 +9,12 @@
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Product\Brand\Brand;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class BrandFilterChoiceRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Filter\BrandFilterChoiceRepository
* @inject
diff --git a/tests/App/Functional/Model/Product/Filter/FlagFilterChoiceRepositoryTest.php b/tests/App/Functional/Model/Product/Filter/FlagFilterChoiceRepositoryTest.php
index 7ffca9c2a6..fde9d588c1 100644
--- a/tests/App/Functional/Model/Product/Filter/FlagFilterChoiceRepositoryTest.php
+++ b/tests/App/Functional/Model/Product/Filter/FlagFilterChoiceRepositoryTest.php
@@ -9,9 +9,12 @@
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Product\Flag\Flag;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class FlagFilterChoiceRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Filter\FlagFilterChoiceRepository
* @inject
diff --git a/tests/App/Functional/Model/Product/Filter/ParameterFilterChoiceRepositoryTest.php b/tests/App/Functional/Model/Product/Filter/ParameterFilterChoiceRepositoryTest.php
index cf7f55eb89..a29ef09dba 100644
--- a/tests/App/Functional/Model/Product/Filter/ParameterFilterChoiceRepositoryTest.php
+++ b/tests/App/Functional/Model/Product/Filter/ParameterFilterChoiceRepositoryTest.php
@@ -8,9 +8,12 @@
use App\DataFixtures\Demo\PricingGroupDataFixture;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Tests\App\Test\ParameterTransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ParameterFilterChoiceRepositoryTest extends ParameterTransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Filter\ParameterFilterChoiceRepository
* @inject
diff --git a/tests/App/Functional/Model/Product/ProductDomainTest.php b/tests/App/Functional/Model/Product/ProductDomainTest.php
index fd638c7dc1..769d3de5e8 100644
--- a/tests/App/Functional/Model/Product/ProductDomainTest.php
+++ b/tests/App/Functional/Model/Product/ProductDomainTest.php
@@ -8,9 +8,12 @@
use App\Model\Product\Product;
use App\Model\Product\ProductData;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductDomainTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_ID = 1;
protected const SECOND_DOMAIN_ID = 2;
protected const DEMONSTRATIVE_DESCRIPTION = 'Demonstrative description';
@@ -31,23 +34,12 @@ class ProductDomainTest extends TransactionFunctionalTestCase
*/
private $productFactory;
- /**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
- */
- private $em;
-
/**
* @var \Shopsys\FrameworkBundle\Model\Pricing\Vat\VatFacade
* @inject
*/
private $vatFacade;
- public function setUp()
- {
- parent::setUp();
- $this->em = $this->getEntityManager();
- }
-
/**
* @group multidomain
*/
diff --git a/tests/App/Functional/Model/Product/ProductFacadeTest.php b/tests/App/Functional/Model/Product/ProductFacadeTest.php
index 1331a07b69..f398454136 100644
--- a/tests/App/Functional/Model/Product/ProductFacadeTest.php
+++ b/tests/App/Functional/Model/Product/ProductFacadeTest.php
@@ -11,9 +11,12 @@
use App\Model\Product\ProductData;
use ReflectionClass;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductDataFactoryInterface
* @inject
@@ -68,7 +71,7 @@ public function testHandleOutOfStockState(
$product = $this->productFacade->create($productData);
- $this->getEntityManager()->clear();
+ $this->em->clear();
$productFromDb = $this->productFacade->getById($product->getId());
diff --git a/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeCountDataTest.php b/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeCountDataTest.php
index 2f77f4e4aa..755a326398 100644
--- a/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeCountDataTest.php
+++ b/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeCountDataTest.php
@@ -5,9 +5,12 @@
namespace Tests\App\Functional\Model\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacadeInterface;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductOnCurrentDomainElasticFacadeCountDataTest extends ProductOnCurrentDomainFacadeCountDataTest
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainElasticFacade
* @inject
diff --git a/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeTest.php b/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeTest.php
index de431e0b5b..1d9d5bf008 100644
--- a/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeTest.php
+++ b/tests/App/Functional/Model/Product/ProductOnCurrentDomainElasticFacadeTest.php
@@ -5,9 +5,12 @@
namespace Tests\App\Functional\Model\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacadeInterface;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductOnCurrentDomainElasticFacadeTest extends ProductOnCurrentDomainFacadeTest
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainElasticFacade
* @inject
diff --git a/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeCountDataTest.php b/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeCountDataTest.php
index ed3fa047e0..c0246eb7af 100644
--- a/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeCountDataTest.php
+++ b/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeCountDataTest.php
@@ -15,9 +15,12 @@
use Shopsys\FrameworkBundle\Model\Product\Parameter\ParameterValue;
use Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacadeInterface;
use Tests\App\Test\ParameterTransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
abstract class ProductOnCurrentDomainFacadeCountDataTest extends ParameterTransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterConfigFactory
* @inject
@@ -41,7 +44,7 @@ abstract class ProductOnCurrentDomainFacadeCountDataTest extends ParameterTransa
*/
protected $productOnCurrentDomainFacade;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->productOnCurrentDomainFacade = $this->getProductOnCurrentDomainFacade();
@@ -90,7 +93,7 @@ public function testSearch(): void
$this->skipTestIfFirstDomainIsNotInEnglish();
foreach ($this->searchTestCasesProvider() as $dataProvider) {
- /** @var string $category */
+ /** @var string $searchText */
$searchText = $dataProvider[0];
/** @var \Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterData $filterData */
$filterData = $dataProvider[1];
@@ -637,14 +640,12 @@ private function createParameterFilterData(array $namesByLocale, array $valuesTe
*/
private function getParameterValuesByLocalesAndTexts(array $valuesTextsByLocales)
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
$parameterValues = [];
foreach ($valuesTextsByLocales as $valueTextsByLocales) {
foreach ($valueTextsByLocales as $locale => $text) {
/** @var \Shopsys\FrameworkBundle\Model\Product\Parameter\ParameterValue $parameterValue */
- $parameterValue = $em->getRepository(ParameterValue::class)->findOneBy([
+ $parameterValue = $this->em->getRepository(ParameterValue::class)->findOneBy([
'text' => $text,
'locale' => $locale,
]);
diff --git a/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeTest.php b/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeTest.php
index 131a493b0e..41dfa1b62e 100644
--- a/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeTest.php
+++ b/tests/App/Functional/Model/Product/ProductOnCurrentDomainFacadeTest.php
@@ -18,9 +18,12 @@
use Shopsys\FrameworkBundle\Model\Product\Parameter\ParameterValue;
use Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacadeInterface;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
abstract class ProductOnCurrentDomainFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Parameter\ParameterRepository
* @inject
@@ -226,14 +229,12 @@ private function createParameterFilterData(array $namesByLocale, array $valuesTe
*/
private function getParameterValuesByLocalesAndTexts(array $valuesTextsByLocales)
{
- /** @var \Doctrine\ORM\EntityManager $em */
- $em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
$parameterValues = [];
foreach ($valuesTextsByLocales as $valueTextsByLocales) {
foreach ($valueTextsByLocales as $locale => $text) {
/** @var \Shopsys\FrameworkBundle\Model\Product\Parameter\ParameterValue $parameterValue */
- $parameterValue = $em->getRepository(ParameterValue::class)->findOneBy([
+ $parameterValue = $this->em->getRepository(ParameterValue::class)->findOneBy([
'text' => $text,
'locale' => $locale,
]);
diff --git a/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeCountDataTest.php b/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeCountDataTest.php
index a09bb7b6c6..52362160f3 100644
--- a/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeCountDataTest.php
+++ b/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeCountDataTest.php
@@ -5,9 +5,12 @@
namespace Tests\App\Functional\Model\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacadeInterface;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductOnCurrentDomainSqlFacadeCountDataTest extends ProductOnCurrentDomainFacadeCountDataTest
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacade
* @inject
diff --git a/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeTest.php b/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeTest.php
index cf3d3392b7..4f4ecb7a78 100644
--- a/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeTest.php
+++ b/tests/App/Functional/Model/Product/ProductOnCurrentDomainSqlFacadeTest.php
@@ -5,9 +5,12 @@
namespace Tests\App\Functional\Model\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacadeInterface;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductOnCurrentDomainSqlFacadeTest extends ProductOnCurrentDomainFacadeTest
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductOnCurrentDomainFacade
* @inject
diff --git a/tests/App/Functional/Model/Product/ProductRepositoryTest.php b/tests/App/Functional/Model/Product/ProductRepositoryTest.php
index 19e0136a13..95cccbd1f1 100644
--- a/tests/App/Functional/Model/Product/ProductRepositoryTest.php
+++ b/tests/App/Functional/Model/Product/ProductRepositoryTest.php
@@ -13,9 +13,12 @@
use Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterData;
use Shopsys\FrameworkBundle\Model\Product\Listing\ProductListOrderingConfig;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductRepository
* @inject
@@ -202,10 +205,13 @@ public function testGetSortedProductsByIds()
/** @var \Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup $pricingGroup */
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID);
- /** @var \App\Model\Product\Product $product */
+ /** @var \App\Model\Product\Product $product1 */
$product1 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . 1);
+ /** @var \App\Model\Product\Product $product2 */
$product2 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . 2);
+ /** @var \App\Model\Product\Product $product3 */
$product3 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . 3);
+ /** @var \App\Model\Product\Product $product4 */
$product4 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . 4);
$sortedProducts = [
diff --git a/tests/App/Functional/Model/Product/ProductSellingDeniedRecalculatorTest.php b/tests/App/Functional/Model/Product/ProductSellingDeniedRecalculatorTest.php
index b150ca829c..f5afa40f20 100644
--- a/tests/App/Functional/Model/Product/ProductSellingDeniedRecalculatorTest.php
+++ b/tests/App/Functional/Model/Product/ProductSellingDeniedRecalculatorTest.php
@@ -6,9 +6,12 @@
use App\DataFixtures\Demo\ProductDataFixture;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductSellingDeniedRecalculatorTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductSellingDeniedRecalculator
* @inject
@@ -29,8 +32,6 @@ class ProductSellingDeniedRecalculatorTest extends TransactionFunctionalTestCase
public function testCalculateSellingDeniedForProductSellableVariant()
{
- $em = $this->getEntityManager();
-
/** @var \App\Model\Product\Product $variant1 */
$variant1 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . '53');
/** @var \App\Model\Product\Product $variant2 */
@@ -46,10 +47,10 @@ public function testCalculateSellingDeniedForProductSellableVariant()
$this->productSellingDeniedRecalculator->calculateSellingDeniedForProduct($variant1);
- $em->refresh($variant1);
- $em->refresh($variant2);
- $em->refresh($variant3);
- $em->refresh($mainVariant);
+ $this->em->refresh($variant1);
+ $this->em->refresh($variant2);
+ $this->em->refresh($variant3);
+ $this->em->refresh($mainVariant);
$this->assertTrue($variant1->getCalculatedSellingDenied());
$this->assertFalse($variant2->getCalculatedSellingDenied());
@@ -59,8 +60,6 @@ public function testCalculateSellingDeniedForProductSellableVariant()
public function testCalculateSellingDeniedForProductNotSellableVariants()
{
- $em = $this->getEntityManager();
-
/** @var \App\Model\Product\Product $variant1 */
$variant1 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . '53');
/** @var \App\Model\Product\Product $variant2 */
@@ -82,10 +81,10 @@ public function testCalculateSellingDeniedForProductNotSellableVariants()
$this->productSellingDeniedRecalculator->calculateSellingDeniedForProduct($mainVariant);
- $em->refresh($variant1);
- $em->refresh($variant2);
- $em->refresh($variant3);
- $em->refresh($mainVariant);
+ $this->em->refresh($variant1);
+ $this->em->refresh($variant2);
+ $this->em->refresh($variant3);
+ $this->em->refresh($mainVariant);
$this->assertTrue($variant1->getCalculatedSellingDenied());
$this->assertTrue($variant2->getCalculatedSellingDenied());
@@ -95,8 +94,6 @@ public function testCalculateSellingDeniedForProductNotSellableVariants()
public function testCalculateSellingDeniedForProductNotSellableMainVariant()
{
- $em = $this->getEntityManager();
-
/** @var \App\Model\Product\Product $variant1 */
$variant1 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . '53');
/** @var \App\Model\Product\Product $variant2 */
@@ -112,10 +109,10 @@ public function testCalculateSellingDeniedForProductNotSellableMainVariant()
$this->productSellingDeniedRecalculator->calculateSellingDeniedForProduct($mainVariant);
- $em->refresh($variant1);
- $em->refresh($variant2);
- $em->refresh($variant3);
- $em->refresh($mainVariant);
+ $this->em->refresh($variant1);
+ $this->em->refresh($variant2);
+ $this->em->refresh($variant3);
+ $this->em->refresh($mainVariant);
$this->assertTrue($variant1->getCalculatedSellingDenied());
$this->assertTrue($variant2->getCalculatedSellingDenied());
diff --git a/tests/App/Functional/Model/Product/ProductVariantCreationTest.php b/tests/App/Functional/Model/Product/ProductVariantCreationTest.php
index 71ace0620e..a73041a130 100644
--- a/tests/App/Functional/Model/Product/ProductVariantCreationTest.php
+++ b/tests/App/Functional/Model/Product/ProductVariantCreationTest.php
@@ -8,9 +8,12 @@
use Shopsys\FrameworkBundle\Model\Product\Product;
use Shopsys\FrameworkBundle\Model\Product\ProductData;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
final class ProductVariantCreationTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductFacade
* @inject
diff --git a/tests/App/Functional/Model/Product/ProductVisibilityRepositoryTest.php b/tests/App/Functional/Model/Product/ProductVisibilityRepositoryTest.php
index 8f28211a40..205823461b 100644
--- a/tests/App/Functional/Model/Product/ProductVisibilityRepositoryTest.php
+++ b/tests/App/Functional/Model/Product/ProductVisibilityRepositoryTest.php
@@ -18,9 +18,12 @@
use Shopsys\FrameworkBundle\Model\Product\ProductData;
use Shopsys\FrameworkBundle\Model\Product\ProductVisibility;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ProductVisibilityRepositoryTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\ProductDataFactoryInterface
* @inject
@@ -87,14 +90,12 @@ private function getDefaultProductData()
private function setVatsForAllDomains(ProductData $productData): void
{
$productVats = [];
- $em = $this->getEntityManager();
-
foreach ($this->domain->getAllIds() as $domainId) {
$vatData = new VatData();
$vatData->name = 'vat';
$vatData->percent = '21';
$vat = new Vat($vatData, $domainId);
- $em->persist($vat);
+ $this->em->persist($vat);
$productVats[$domainId] = $vat;
}
@@ -119,27 +120,25 @@ private function setPriceForAllDomains(ProductData $productData, ?Money $price)
public function testIsVisibleOnAnyDomainWhenHidden()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$productData->hidden = true;
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->flush();
+ $this->em->flush();
$id = $product->getId();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \App\Model\Product\Product $productAgain */
- $productAgain = $em->getRepository(Product::class)->find($id);
+ $productAgain = $this->em->getRepository(Product::class)->find($id);
/** @var \Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup $pricingGroup */
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID);
/** @var \Shopsys\FrameworkBundle\Model\Product\ProductVisibility $productVisibility1 */
- $productVisibility1 = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility1 = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $productAgain,
'pricingGroup' => $pricingGroup->getId(),
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -151,26 +150,24 @@ public function testIsVisibleOnAnyDomainWhenHidden()
public function testIsVisibleOnAnyDomainWhenNotHidden()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->flush();
+ $this->em->flush();
$id = $product->getId();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \App\Model\Product\Product $productAgain */
- $productAgain = $em->getRepository(Product::class)->find($id);
+ $productAgain = $this->em->getRepository(Product::class)->find($id);
/** @var \Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup $pricingGroup */
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID);
/** @var \Shopsys\FrameworkBundle\Model\Product\ProductVisibility $productVisibility1 */
- $productVisibility1 = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility1 = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $productAgain->getId(),
'pricingGroup' => $pricingGroup->getId(),
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -182,8 +179,6 @@ public function testIsVisibleOnAnyDomainWhenNotHidden()
public function testIsVisibleOnAnyDomainWhenSellingInFuture()
{
- $em = $this->getEntityManager();
-
$sellingFrom = new DateTime('now');
$sellingFrom->modify('+1 day');
@@ -192,22 +187,20 @@ public function testIsVisibleOnAnyDomainWhenSellingInFuture()
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->flush();
+ $this->em->flush();
$id = $product->getId();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \App\Model\Product\Product $productAgain */
- $productAgain = $em->getRepository(Product::class)->find($id);
+ $productAgain = $this->em->getRepository(Product::class)->find($id);
$this->assertFalse($productAgain->isVisible());
}
public function testIsVisibleOnAnyDomainWhenSellingInPast()
{
- $em = $this->getEntityManager();
-
$sellingTo = new DateTime('now');
$sellingTo->modify('-1 day');
@@ -216,22 +209,20 @@ public function testIsVisibleOnAnyDomainWhenSellingInPast()
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->flush();
+ $this->em->flush();
$id = $product->getId();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \App\Model\Product\Product $productAgain */
- $productAgain = $em->getRepository(Product::class)->find($id);
+ $productAgain = $this->em->getRepository(Product::class)->find($id);
$this->assertFalse($productAgain->isVisible());
}
public function testIsVisibleOnAnyDomainWhenSellingNow()
{
- $em = $this->getEntityManager();
-
$sellingFrom = new DateTime('now');
$sellingFrom->modify('-1 day');
$sellingTo = new DateTime('now');
@@ -243,22 +234,20 @@ public function testIsVisibleOnAnyDomainWhenSellingNow()
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->flush();
+ $this->em->flush();
$id = $product->getId();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \App\Model\Product\Product $productAgain */
- $productAgain = $em->getRepository(Product::class)->find($id);
+ $productAgain = $this->em->getRepository(Product::class)->find($id);
$this->assertTrue($productAgain->isVisible());
}
public function testIsNotVisibleWhenZeroOrNullPrice()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$this->setPriceForAllDomains($productData, Money::zero());
$product1 = $this->productFacade->create($productData);
@@ -269,14 +258,14 @@ public function testIsNotVisibleWhenZeroOrNullPrice()
$product1Id = $product1->getId();
$product2Id = $product2->getId();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \App\Model\Product\Product $product1Again */
- $product1Again = $em->getRepository(Product::class)->find($product1Id);
+ $product1Again = $this->em->getRepository(Product::class)->find($product1Id);
/** @var \App\Model\Product\Product $product2Again */
- $product2Again = $em->getRepository(Product::class)->find($product2Id);
+ $product2Again = $this->em->getRepository(Product::class)->find($product2Id);
$this->assertFalse($product1Again->isVisible());
$this->assertFalse($product2Again->isVisible());
@@ -284,13 +273,11 @@ public function testIsNotVisibleWhenZeroOrNullPrice()
public function testIsVisibleWithFilledName()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
@@ -298,7 +285,7 @@ public function testIsVisibleWithFilledName()
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID);
/** @var \Shopsys\FrameworkBundle\Model\Product\ProductVisibility $productVisibility */
- $productVisibility = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $product,
'pricingGroup' => $pricingGroup->getId(),
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -309,14 +296,12 @@ public function testIsVisibleWithFilledName()
public function testIsNotVisibleWithEmptyName()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$productData->name = ['cs' => null, 'en' => null];
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
@@ -324,7 +309,7 @@ public function testIsNotVisibleWithEmptyName()
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID);
/** @var \Shopsys\FrameworkBundle\Model\Product\ProductVisibility $productVisibility */
- $productVisibility = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $product,
'pricingGroup' => $pricingGroup->getId(),
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -335,8 +320,6 @@ public function testIsNotVisibleWithEmptyName()
public function testIsVisibleInVisibileCategory()
{
- $em = $this->getEntityManager();
-
/** @var \App\Model\Category\Category $category */
$category = $this->getReference(CategoryDataFixture::CATEGORY_TOYS);
@@ -345,7 +328,7 @@ public function testIsVisibleInVisibileCategory()
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
@@ -353,7 +336,7 @@ public function testIsVisibleInVisibileCategory()
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID);
/** @var \Shopsys\FrameworkBundle\Model\Product\ProductVisibility $productVisibility */
- $productVisibility = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $product,
'pricingGroup' => $pricingGroup->getId(),
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -364,21 +347,19 @@ public function testIsVisibleInVisibileCategory()
public function testIsNotVisibleInHiddenCategory()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$productData->categoriesByDomainId = [];
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroup $pricingGroup */
$pricingGroup = $this->getReferenceForDomain(PricingGroupDataFixture::PRICING_GROUP_ORDINARY, Domain::FIRST_DOMAIN_ID);
- $productVisibility = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $product,
'pricingGroup' => $pricingGroup->getId(),
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -389,8 +370,6 @@ public function testIsNotVisibleInHiddenCategory()
public function testIsNotVisibleWhenZeroManualPrice()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$this->setPriceForAllDomains($productData, Money::create(10));
@@ -403,12 +382,12 @@ public function testIsNotVisibleWhenZeroManualPrice()
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \Shopsys\FrameworkBundle\Model\Product\ProductVisibility $productVisibility */
- $productVisibility = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $product,
'pricingGroup' => $pricingGroupWithZeroPriceId,
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -419,8 +398,6 @@ public function testIsNotVisibleWhenZeroManualPrice()
public function testIsNotVisibleWhenNullManualPrice()
{
- $em = $this->getEntityManager();
-
$productData = $this->getDefaultProductData();
$allPricingGroups = $this->pricingGroupFacade->getAll();
@@ -436,12 +413,12 @@ public function testIsNotVisibleWhenNullManualPrice()
$product = $this->productFacade->create($productData);
$this->productPriceRecalculator->runImmediateRecalculations();
- $em->clear();
+ $this->em->clear();
$this->productVisibilityRepository->refreshProductsVisibility();
/** @var \Shopsys\FrameworkBundle\Model\Product\ProductVisibility $productVisibility */
- $productVisibility = $em->getRepository(ProductVisibility::class)->findOneBy([
+ $productVisibility = $this->em->getRepository(ProductVisibility::class)->findOneBy([
'product' => $product,
'pricingGroup' => $pricingGroupWithNullPriceId,
'domainId' => Domain::FIRST_DOMAIN_ID,
@@ -452,8 +429,6 @@ public function testIsNotVisibleWhenNullManualPrice()
public function testRefreshProductsVisibilityVisibleVariants()
{
- $em = $this->getEntityManager();
-
/** @var \App\Model\Product\Product $variant1 */
$variant1 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . '53');
/** @var \App\Model\Product\Product $variant2 */
@@ -469,10 +444,10 @@ public function testRefreshProductsVisibilityVisibleVariants()
$this->productVisibilityRepository->refreshProductsVisibility(true);
- $em->refresh($variant1);
- $em->refresh($variant2);
- $em->refresh($variant3);
- $em->refresh($mainVariant);
+ $this->em->refresh($variant1);
+ $this->em->refresh($variant2);
+ $this->em->refresh($variant3);
+ $this->em->refresh($mainVariant);
$this->assertFalse($variant1->isVisible());
$this->assertTrue($variant2->isVisible());
@@ -482,8 +457,6 @@ public function testRefreshProductsVisibilityVisibleVariants()
public function testRefreshProductsVisibilityNotVisibleVariants()
{
- $em = $this->getEntityManager();
-
/** @var \App\Model\Product\Product $variant1 */
$variant1 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . '53');
/** @var \App\Model\Product\Product $variant2 */
@@ -507,10 +480,10 @@ public function testRefreshProductsVisibilityNotVisibleVariants()
$this->productVisibilityRepository->refreshProductsVisibility(true);
- $em->refresh($variant1);
- $em->refresh($variant2);
- $em->refresh($variant3);
- $em->refresh($mainVariant);
+ $this->em->refresh($variant1);
+ $this->em->refresh($variant2);
+ $this->em->refresh($variant3);
+ $this->em->refresh($mainVariant);
$this->assertFalse($variant1->isVisible());
$this->assertFalse($variant2->isVisible());
@@ -520,8 +493,6 @@ public function testRefreshProductsVisibilityNotVisibleVariants()
public function testRefreshProductsVisibilityNotVisibleMainVariant()
{
- $em = $this->getEntityManager();
-
/** @var \App\Model\Product\Product $variant1 */
$variant1 = $this->getReference(ProductDataFixture::PRODUCT_PREFIX . '53');
/** @var \App\Model\Product\Product $variant2 */
@@ -537,10 +508,10 @@ public function testRefreshProductsVisibilityNotVisibleMainVariant()
$this->productVisibilityRepository->refreshProductsVisibility(true);
- $em->refresh($variant1);
- $em->refresh($variant2);
- $em->refresh($variant3);
- $em->refresh($mainVariant);
+ $this->em->refresh($variant1);
+ $this->em->refresh($variant2);
+ $this->em->refresh($variant3);
+ $this->em->refresh($mainVariant);
$this->assertFalse($variant1->isVisible());
$this->assertFalse($variant2->isVisible());
diff --git a/tests/App/Functional/Model/Product/Search/FilterQueryTest.php b/tests/App/Functional/Model/Product/Search/FilterQueryTest.php
index 13d4912f42..2c2c9d8df9 100644
--- a/tests/App/Functional/Model/Product/Search/FilterQueryTest.php
+++ b/tests/App/Functional/Model/Product/Search/FilterQueryTest.php
@@ -11,9 +11,12 @@
use Shopsys\FrameworkBundle\Model\Product\Listing\ProductListOrderingConfig;
use Shopsys\FrameworkBundle\Model\Product\Search\FilterQuery;
use Tests\App\Test\ParameterTransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class FilterQueryTest extends ParameterTransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Elasticsearch\Client
* @inject
diff --git a/tests/App/Functional/Model/Security/AuthenticatorTest.php b/tests/App/Functional/Model/Security/AuthenticatorTest.php
index 4b0f6c860c..3e3b174e6d 100644
--- a/tests/App/Functional/Model/Security/AuthenticatorTest.php
+++ b/tests/App/Functional/Model/Security/AuthenticatorTest.php
@@ -8,9 +8,12 @@
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class AuthenticatorTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Security\Authenticator
* @inject
diff --git a/tests/App/Functional/Model/Transport/IndependentTransportVisibilityCalculationTest.php b/tests/App/Functional/Model/Transport/IndependentTransportVisibilityCalculationTest.php
index de2197cca0..7cea8b33fd 100644
--- a/tests/App/Functional/Model/Transport/IndependentTransportVisibilityCalculationTest.php
+++ b/tests/App/Functional/Model/Transport/IndependentTransportVisibilityCalculationTest.php
@@ -7,9 +7,12 @@
use App\Model\Transport\Transport;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class IndependentTransportVisibilityCalculationTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Localization\Localization
* @inject
@@ -30,8 +33,6 @@ class IndependentTransportVisibilityCalculationTest extends TransactionFunctiona
public function testIsIndependentlyVisible()
{
- $em = $this->getEntityManager();
-
$enabledOnDomains = [
Domain::FIRST_DOMAIN_ID => true,
Domain::SECOND_DOMAIN_ID => false,
@@ -39,16 +40,14 @@ public function testIsIndependentlyVisible()
$transport = $this->getDefaultTransport($enabledOnDomains, false);
- $em->persist($transport);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->flush();
$this->assertTrue($this->independentTransportVisibilityCalculation->isIndependentlyVisible($transport, Domain::FIRST_DOMAIN_ID));
}
public function testIsIndependentlyVisibleEmptyName()
{
- $em = $this->getEntityManager();
-
$transportData = $this->transportDataFactory->create();
$names = [];
foreach ($this->localization->getLocalesOfAllDomains() as $locale) {
@@ -63,16 +62,14 @@ public function testIsIndependentlyVisibleEmptyName()
$transport = new Transport($transportData);
- $em->persist($transport);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->flush();
$this->assertFalse($this->independentTransportVisibilityCalculation->isIndependentlyVisible($transport, Domain::FIRST_DOMAIN_ID));
}
public function testIsIndependentlyVisibleNotOnDomain()
{
- $em = $this->getEntityManager();
-
$enabledOnDomains = [
Domain::FIRST_DOMAIN_ID => false,
Domain::SECOND_DOMAIN_ID => false,
@@ -80,16 +77,14 @@ public function testIsIndependentlyVisibleNotOnDomain()
$transport = $this->getDefaultTransport($enabledOnDomains, false);
- $em->persist($transport);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->flush();
$this->assertFalse($this->independentTransportVisibilityCalculation->isIndependentlyVisible($transport, Domain::FIRST_DOMAIN_ID));
}
public function testIsIndependentlyVisibleHidden()
{
- $em = $this->getEntityManager();
-
$enabledOnDomains = [
Domain::FIRST_DOMAIN_ID => true,
Domain::SECOND_DOMAIN_ID => false,
@@ -97,8 +92,8 @@ public function testIsIndependentlyVisibleHidden()
$transport = $this->getDefaultTransport($enabledOnDomains, true);
- $em->persist($transport);
- $em->flush();
+ $this->em->persist($transport);
+ $this->em->flush();
$this->assertFalse($this->independentTransportVisibilityCalculation->isIndependentlyVisible($transport, Domain::FIRST_DOMAIN_ID));
}
diff --git a/tests/App/Functional/Model/Transport/TransportDomainTest.php b/tests/App/Functional/Model/Transport/TransportDomainTest.php
index 1efb88fba5..16c38af99f 100644
--- a/tests/App/Functional/Model/Transport/TransportDomainTest.php
+++ b/tests/App/Functional/Model/Transport/TransportDomainTest.php
@@ -6,9 +6,12 @@
use App\Model\Transport\Transport;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class TransportDomainTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const FIRST_DOMAIN_ID = 1;
protected const SECOND_DOMAIN_ID = 2;
@@ -24,17 +27,6 @@ class TransportDomainTest extends TransactionFunctionalTestCase
*/
private $transportFactory;
- /**
- * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
- */
- private $em;
-
- public function setUp()
- {
- parent::setUp();
- $this->em = $this->getEntityManager();
- }
-
public function testCreateTransportEnabledOnDomain()
{
$transportData = $this->transportDataFactory->create();
diff --git a/tests/App/Functional/Model/Unit/UnitFacadeTest.php b/tests/App/Functional/Model/Unit/UnitFacadeTest.php
index 98ac0908a3..dc7b2de484 100644
--- a/tests/App/Functional/Model/Unit/UnitFacadeTest.php
+++ b/tests/App/Functional/Model/Unit/UnitFacadeTest.php
@@ -8,9 +8,12 @@
use App\DataFixtures\Demo\UnitDataFixture;
use Shopsys\FrameworkBundle\Model\Product\Unit\UnitData;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class UnitFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Product\Unit\UnitFacade
* @inject
@@ -31,8 +34,6 @@ class UnitFacadeTest extends TransactionFunctionalTestCase
public function testDeleteByIdAndReplace()
{
- $em = $this->getEntityManager();
-
$unitData = new UnitData();
$unitData->name = ['cs' => 'name'];
$unitToDelete = $this->unitFacade->create($unitData);
@@ -47,7 +48,7 @@ public function testDeleteByIdAndReplace()
$this->unitFacade->deleteById($unitToDelete->getId(), $unitToReplaceWith->getId());
- $em->refresh($product);
+ $this->em->refresh($product);
$this->assertEquals($unitToReplaceWith, $product->getUnit());
}
diff --git a/tests/App/Functional/Model/Vat/VatFacadeTest.php b/tests/App/Functional/Model/Vat/VatFacadeTest.php
index 68b81029b1..376fbbe6dc 100644
--- a/tests/App/Functional/Model/Vat/VatFacadeTest.php
+++ b/tests/App/Functional/Model/Vat/VatFacadeTest.php
@@ -10,9 +10,12 @@
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Model\Pricing\Vat\VatData;
use Tests\App\Test\TransactionFunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class VatFacadeTest extends TransactionFunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Model\Pricing\Vat\VatFacade
* @inject
@@ -45,8 +48,6 @@ class VatFacadeTest extends TransactionFunctionalTestCase
public function testDeleteByIdAndReplaceForFirstDomain()
{
- $em = $this->getEntityManager();
-
$vatData = new VatData();
$vatData->name = 'name';
$vatData->percent = '10';
@@ -71,8 +72,8 @@ public function testDeleteByIdAndReplaceForFirstDomain()
$this->vatFacade->deleteById($vatToDelete, $vatToReplaceWith);
- $em->refresh($transport->getTransportDomain(Domain::FIRST_DOMAIN_ID));
- $em->refresh($payment->getPaymentDomain(Domain::FIRST_DOMAIN_ID));
+ $this->em->refresh($transport->getTransportDomain(Domain::FIRST_DOMAIN_ID));
+ $this->em->refresh($payment->getPaymentDomain(Domain::FIRST_DOMAIN_ID));
$this->assertEquals($vatToReplaceWith, $payment->getPaymentDomain(Domain::FIRST_DOMAIN_ID)->getVat());
$this->assertEquals($vatToReplaceWith, $transport->getTransportDomain(Domain::FIRST_DOMAIN_ID)->getVat());
diff --git a/tests/App/Functional/Twig/ImageExtensionTest.php b/tests/App/Functional/Twig/ImageExtensionTest.php
index 3c9e21dd2e..228bb86fe3 100644
--- a/tests/App/Functional/Twig/ImageExtensionTest.php
+++ b/tests/App/Functional/Twig/ImageExtensionTest.php
@@ -9,9 +9,12 @@
use Shopsys\FrameworkBundle\Component\Image\ImageFacade;
use Shopsys\FrameworkBundle\Twig\ImageExtension;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ImageExtensionTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\FrameworkBundle\Component\Image\ImageLocator
* @inject
@@ -20,7 +23,7 @@ class ImageExtensionTest extends FunctionalTestCase
public function testGetImageHtmlWithAdditional(): void
{
- $templating = $this->getContainer()->get('templating');
+ $templating = $this->getContainer()->get('twig');
$imageFacade = $this->createMock(ImageFacade::class);
diff --git a/tests/App/Functional/Twig/NumberFormatterExtensionTest.php b/tests/App/Functional/Twig/NumberFormatterExtensionTest.php
index f57db44ac6..51fde2793a 100644
--- a/tests/App/Functional/Twig/NumberFormatterExtensionTest.php
+++ b/tests/App/Functional/Twig/NumberFormatterExtensionTest.php
@@ -4,19 +4,17 @@
namespace Tests\App\Functional\Twig;
+use CommerceGuys\Intl\NumberFormat\NumberFormatRepository;
use Shopsys\FrameworkBundle\Model\Localization\Localization;
use Shopsys\FrameworkBundle\Twig\NumberFormatterExtension;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class NumberFormatterExtensionTest extends FunctionalTestCase
{
- protected const NBSP = "\xc2\xa0";
+ use SymfonyTestContainer;
- /**
- * @var \CommerceGuys\Intl\NumberFormat\NumberFormatRepository
- * @inject
- */
- private $numberFormatRepository;
+ protected const NBSP = "\xc2\xa0";
/**
* @var \Shopsys\FrameworkBundle\Model\Administration\AdministrationFacade
@@ -60,7 +58,7 @@ public function testFormatNumber($input, $locale, $result)
$localizationMock->expects($this->any())->method('getLocale')
->willReturn($locale);
- $numberFormatterExtension = new NumberFormatterExtension($localizationMock, $this->numberFormatRepository, $this->administrationFacade);
+ $numberFormatterExtension = new NumberFormatterExtension($localizationMock, new NumberFormatRepository(), $this->administrationFacade);
$this->assertSame($result, $numberFormatterExtension->formatNumber($input, $locale));
}
diff --git a/tests/App/Functional/Twig/PriceExtensionTest.php b/tests/App/Functional/Twig/PriceExtensionTest.php
index 40c289f072..d760418ccb 100644
--- a/tests/App/Functional/Twig/PriceExtensionTest.php
+++ b/tests/App/Functional/Twig/PriceExtensionTest.php
@@ -4,20 +4,22 @@
namespace Tests\App\Functional\Twig;
+use CommerceGuys\Intl\NumberFormat\NumberFormatRepository;
use Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Component\Money\Money;
use Shopsys\FrameworkBundle\Component\Setting\Setting;
use Shopsys\FrameworkBundle\Model\Localization\Localization;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\Currency;
-use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyDataFactoryInterface;
use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade;
-use Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFactoryInterface;
use Shopsys\FrameworkBundle\Twig\PriceExtension;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class PriceExtensionTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
protected const NBSP = "\xc2\xa0";
/**
@@ -27,18 +29,24 @@ class PriceExtensionTest extends FunctionalTestCase
private $intlCurrencyRepository;
/**
- * @var \CommerceGuys\Intl\NumberFormat\NumberFormatRepository
+ * @var \Shopsys\FrameworkBundle\Component\CurrencyFormatter\CurrencyFormatterFactory
* @inject
*/
- private $numberFormatRepository;
+ private $currencyFormatterFactory;
/**
- * @var \Shopsys\FrameworkBundle\Component\CurrencyFormatter\CurrencyFormatterFactory
+ * @var \Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFactoryInterface
* @inject
*/
- private $currencyFormatterFactory;
+ private $currencyFactory;
- protected function setUp()
+ /**
+ * @var \Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyDataFactoryInterface
+ * @inject
+ */
+ private $currencyDataFactory;
+
+ protected function setUp(): void
{
$domainConfig1 = new DomainConfig(Domain::FIRST_DOMAIN_ID, 'http://example.com', 'example', 'en');
$domainConfig2 = new DomainConfig(Domain::SECOND_DOMAIN_ID, 'http://example.com', 'example', 'cs');
@@ -116,27 +124,22 @@ public function testPriceFilter($input, $domainId, $result)
*/
private function getPriceExtensionWithMockedConfiguration(): PriceExtension
{
- /** @var \Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFactoryInterface $currencyFactory */
- $currencyFactory = $this->getContainer()->get(CurrencyFactoryInterface::class);
- /** @var \Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyDataFactoryInterface $currencyFactory */
- $currencyDataFactory = $this->getContainer()->get(CurrencyDataFactoryInterface::class);
-
- $domain1DefaultCurrencyData = $currencyDataFactory->create();
+ $domain1DefaultCurrencyData = $this->currencyDataFactory->create();
$domain1DefaultCurrencyData->name = 'Czech crown';
$domain1DefaultCurrencyData->code = Currency::CODE_CZK;
- $domain1DefaultCurrencyData->exchangeRate = 1;
+ $domain1DefaultCurrencyData->exchangeRate = '1';
$domain1DefaultCurrencyData->minFractionDigits = 2;
$domain1DefaultCurrencyData->roundingType = Currency::ROUNDING_TYPE_INTEGER;
- $domain2DefaultCurrencyData = $currencyDataFactory->create();
+ $domain2DefaultCurrencyData = $this->currencyDataFactory->create();
$domain2DefaultCurrencyData->name = 'Euro';
$domain2DefaultCurrencyData->code = Currency::CODE_EUR;
- $domain2DefaultCurrencyData->exchangeRate = 25;
+ $domain2DefaultCurrencyData->exchangeRate = '25';
$domain1DefaultCurrencyData->minFractionDigits = 2;
$domain1DefaultCurrencyData->roundingType = Currency::ROUNDING_TYPE_INTEGER;
- $domain1DefaultCurrency = $currencyFactory->create($domain1DefaultCurrencyData);
- $domain2DefaultCurrency = $currencyFactory->create($domain2DefaultCurrencyData);
+ $domain1DefaultCurrency = $this->currencyFactory->create($domain1DefaultCurrencyData);
+ $domain2DefaultCurrency = $this->currencyFactory->create($domain2DefaultCurrencyData);
/** @var \Shopsys\FrameworkBundle\Model\Pricing\Currency\CurrencyFacade|\PHPUnit\Framework\MockObject\MockObject $currencyFacadeMock */
$currencyFacadeMock = $this->getMockBuilder(CurrencyFacade::class)
@@ -158,7 +161,7 @@ private function getPriceExtensionWithMockedConfiguration(): PriceExtension
$currencyFacadeMock,
$this->domain,
$localization,
- $this->numberFormatRepository,
+ new NumberFormatRepository(),
$this->intlCurrencyRepository,
$this->currencyFormatterFactory
);
diff --git a/tests/App/Functional/Twig/TwigEnvironmentTest.php b/tests/App/Functional/Twig/TwigEnvironmentTest.php
index 14d51670c0..84cf5a99f0 100644
--- a/tests/App/Functional/Twig/TwigEnvironmentTest.php
+++ b/tests/App/Functional/Twig/TwigEnvironmentTest.php
@@ -17,7 +17,7 @@ public function testGetFilterMethodIsCallableOnTwigEnvironment()
{
$twigEnvironment = $this->getContainer()->get('twig');
if (!is_callable([$twigEnvironment, 'getFilter'])) {
- $this->fail('Method "getFilter" is not callable on Twig_Environment class');
+ $this->fail('Method "getFilter" is not callable on Twig\Environment class');
}
}
}
diff --git a/tests/App/Performance/Feed/AllFeedsTest.php b/tests/App/Performance/Feed/AllFeedsTest.php
index 93de53db70..b5cccdbe3d 100644
--- a/tests/App/Performance/Feed/AllFeedsTest.php
+++ b/tests/App/Performance/Feed/AllFeedsTest.php
@@ -36,7 +36,7 @@ class AllFeedsTest extends KernelTestCase
*/
private $minDuration;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -45,7 +45,7 @@ protected function setUp()
'debug' => EnvironmentType::isDebug(EnvironmentType::TEST),
]);
- $container = self::$kernel->getContainer();
+ $container = static::bootKernel()->getContainer();
$container->get(Domain::class)
->switchDomainById(Domain::FIRST_DOMAIN_ID);
@@ -89,7 +89,7 @@ public function testAllFeedsGeneration()
$this->exportJmeterCsvReport(
$performanceTestSamples,
- self::$kernel->getContainer()->getParameter('shopsys.root_dir') . '/build/stats/performance-tests-feeds.csv'
+ static::bootKernel()->getContainer()->getParameter('shopsys.root_dir') . '/build/stats/performance-tests-feeds.csv'
);
$this->assertSamplesAreSuccessful($performanceTestSamples);
@@ -115,9 +115,9 @@ private function doTestFeedGeneration(FeedInfoInterface $feedInfo, DomainConfig
public function getAllFeedGenerationData()
{
/** @var \Shopsys\FrameworkBundle\Model\Feed\FeedRegistry $feedRegistry */
- $feedRegistry = self::$kernel->getContainer()->get(FeedRegistry::class);
+ $feedRegistry = static::bootKernel()->getContainer()->get(FeedRegistry::class);
/** @var \Shopsys\FrameworkBundle\Component\Domain\Domain $domain */
- $domain = self::$kernel->getContainer()->get(Domain::class);
+ $domain = static::bootKernel()->getContainer()->get(Domain::class);
$dailyFeedGenerationData = $this->getFeedGenerationData(
$feedRegistry->getFeeds('daily'),
$domain->getAll(),
@@ -184,7 +184,7 @@ private function generateFeed(FeedInfoInterface $feed, DomainConfig $domainConfi
$this->setUp();
/** @var \Symfony\Component\Routing\RouterInterface $router */
- $router = self::$kernel->getContainer()->get('router');
+ $router = static::bootKernel()->getContainer()->get('router');
$uri = $router->generate(
self::ROUTE_NAME_GENERATE_FEED,
@@ -198,7 +198,7 @@ private function generateFeed(FeedInfoInterface $feed, DomainConfig $domainConfi
$auth->authenticateRequest($request);
/** @var \Doctrine\ORM\EntityManager $entityManager */
- $entityManager = self::$kernel->getContainer()->get('doctrine.orm.entity_manager');
+ $entityManager = static::bootKernel()->getContainer()->get('doctrine.orm.entity_manager');
$startTime = microtime(true);
$entityManager->beginTransaction();
diff --git a/tests/App/Performance/Page/AllPagesTest.php b/tests/App/Performance/Page/AllPagesTest.php
index b89fa3afdd..67a32a869d 100644
--- a/tests/App/Performance/Page/AllPagesTest.php
+++ b/tests/App/Performance/Page/AllPagesTest.php
@@ -24,7 +24,7 @@ class AllPagesTest extends KernelTestCase
{
protected const PASSES = 5;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -226,7 +226,6 @@ private function doAssert(
case PerformanceTestSampleQualifier::STATUS_CRITICAL:
default:
$this->fail('Values are above critical threshold');
- return;
}
}
diff --git a/tests/App/Smoke/AllFeedsTest.php b/tests/App/Smoke/AllFeedsTest.php
index c6df4a0882..86ffe7d131 100644
--- a/tests/App/Smoke/AllFeedsTest.php
+++ b/tests/App/Smoke/AllFeedsTest.php
@@ -4,9 +4,7 @@
namespace Tests\App\Smoke;
-use League\Flysystem\FilesystemInterface;
use Shopsys\FrameworkBundle\Component\Domain\Config\DomainConfig;
-use Shopsys\FrameworkBundle\Model\Feed\FeedFacade;
use Shopsys\FrameworkBundle\Model\Feed\FeedInfoInterface;
use Tests\App\Test\FunctionalTestCase;
@@ -14,20 +12,16 @@ class AllFeedsTest extends FunctionalTestCase
{
/**
* @var \Shopsys\FrameworkBundle\Model\Feed\FeedFacade
+ * @inject
*/
private $feedFacade;
/**
* @var \League\Flysystem\FilesystemInterface
+ * @inject
*/
private $filesystem;
- protected function setUp()
- {
- $this->feedFacade = $this->getContainer()->get(FeedFacade::class);
- $this->filesystem = $this->getContainer()->get(FilesystemInterface::class);
- }
-
/**
* @return array
*/
diff --git a/tests/App/Smoke/Http/HttpSmokeTest.php b/tests/App/Smoke/Http/HttpSmokeTest.php
index f0696c6186..7f7c9e2bcc 100644
--- a/tests/App/Smoke/Http/HttpSmokeTest.php
+++ b/tests/App/Smoke/Http/HttpSmokeTest.php
@@ -11,7 +11,7 @@
class HttpSmokeTest extends HttpSmokeTestCase
{
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/App/Smoke/NewProductTest.php b/tests/App/Smoke/NewProductTest.php
index a3f49e2257..37b6178528 100644
--- a/tests/App/Smoke/NewProductTest.php
+++ b/tests/App/Smoke/NewProductTest.php
@@ -7,6 +7,7 @@
use App\DataFixtures\Demo\AvailabilityDataFixture;
use App\DataFixtures\Demo\UnitDataFixture;
use App\DataFixtures\Demo\VatDataFixture;
+use Shopsys\FrameworkBundle\Component\FlashMessage\FlashMessage;
use Shopsys\FrameworkBundle\Form\Admin\Product\ProductFormType;
use Shopsys\FrameworkBundle\Model\Pricing\Group\PricingGroupFacade;
use Symfony\Component\DomCrawler\Form;
@@ -31,13 +32,13 @@ public function testCreateOrEditProduct($relativeUrl)
'HTTP_HOST' => sprintf('%s:%d', parse_url($domainUrl, PHP_URL_HOST), parse_url($domainUrl, PHP_URL_PORT)),
];
- $client1 = $this->getClient(false, 'admin', 'admin123');
+ $client1 = $this->findClient(false, 'admin', 'admin123');
$crawler = $client1->request('GET', $relativeUrl, [], [], $server);
$form = $crawler->filter('form[name=product_form]')->form();
$this->fillForm($form);
- $client2 = $this->getClient(true, 'admin', 'admin123');
+ $client2 = $this->findClient(true, 'admin', 'admin123');
/** @var \Doctrine\ORM\EntityManager $em2 */
$em2 = $client2->getContainer()->get('doctrine.orm.entity_manager');
@@ -52,12 +53,12 @@ public function testCreateOrEditProduct($relativeUrl)
$em2->rollback();
- /** @var \Shopsys\FrameworkBundle\Component\FlashMessage\Bag $flashMessageBag */
- $flashMessageBag = $client2->getContainer()->get('shopsys.shop.component.flash_message.bag.admin');
+ /** @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface $flashBag */
+ $flashBag = $client2->getContainer()->get('session')->getFlashBag();
$this->assertSame(302, $client2->getResponse()->getStatusCode());
- $this->assertNotEmpty($flashMessageBag->getSuccessMessages());
- $this->assertEmpty($flashMessageBag->getErrorMessages());
+ $this->assertNotEmpty($flashBag->get(FlashMessage::KEY_SUCCESS));
+ $this->assertEmpty($flashBag->get(FlashMessage::KEY_ERROR));
}
/**
@@ -125,7 +126,9 @@ private function fillVats(Form $form)
'product_form[pricesGroup][productCalculatedPricesGroup][vatsIndexedByDomainId][%s]',
$domainId
);
- $form[$inputName] = $vat->getId();
+ $form->setValues([
+ $inputName => $vat->getId(),
+ ]);
}
}
}
diff --git a/tests/App/Test/Codeception/AcceptanceTester.php b/tests/App/Test/Codeception/AcceptanceTester.php
index b7fc62ed53..52331c1e56 100644
--- a/tests/App/Test/Codeception/AcceptanceTester.php
+++ b/tests/App/Test/Codeception/AcceptanceTester.php
@@ -50,4 +50,8 @@ public function waitForAjax($timeout = self::DEFAULT_AJAX_TIMEOUT_SEC)
{
$this->waitForJS('return $.active == 0;', $timeout);
}
+
+ public function pauseExecution()
+ {
+ }
}
diff --git a/tests/App/Test/Codeception/Helper/LocalizationHelper.php b/tests/App/Test/Codeception/Helper/LocalizationHelper.php
index 6077ba99de..d57172259b 100644
--- a/tests/App/Test/Codeception/Helper/LocalizationHelper.php
+++ b/tests/App/Test/Codeception/Helper/LocalizationHelper.php
@@ -60,7 +60,7 @@ public function _before(TestInterface $test): void
* @param string $domain
* @param array $parameters
*/
- public function seeTranslationFrontend(string $id, string $domain = 'messages', array $parameters = []): void
+ public function seeTranslationFrontend(string $id, string $domain = 'messages', array $parameters = [])
{
$translatedMessage = t($id, $parameters, $domain, $this->getFrontendLocale());
$this->webDriver->see(strip_tags($translatedMessage));
@@ -71,7 +71,7 @@ public function seeTranslationFrontend(string $id, string $domain = 'messages',
* @param string $domain
* @param array $parameters
*/
- public function dontSeeTranslationFrontend(string $id, string $domain = 'messages', array $parameters = []): void
+ public function dontSeeTranslationFrontend(string $id, string $domain = 'messages', array $parameters = [])
{
$translatedMessage = t($id, $parameters, $domain, $this->getFrontendLocale());
$this->webDriver->dontSee(strip_tags($translatedMessage));
@@ -82,7 +82,7 @@ public function dontSeeTranslationFrontend(string $id, string $domain = 'message
* @param string $domain
* @param array $parameters
*/
- public function seeTranslationAdmin(string $id, string $domain = 'messages', array $parameters = []): void
+ public function seeTranslationAdmin(string $id, string $domain = 'messages', array $parameters = [])
{
$translatedMessage = t($id, $parameters, $domain, $this->getAdminLocale());
$this->webDriver->see(strip_tags($translatedMessage));
@@ -94,7 +94,7 @@ public function seeTranslationAdmin(string $id, string $domain = 'messages', arr
* @param string $domain
* @param array $parameters
*/
- public function seeTranslationAdminInCss(string $id, string $css, string $domain = 'messages', array $parameters = []): void
+ public function seeTranslationAdminInCss(string $id, string $css, string $domain = 'messages', array $parameters = [])
{
$translatedMessage = t($id, $parameters, $domain, $this->getAdminLocale());
$this->webDriver->seeInCss(strip_tags($translatedMessage), $css);
@@ -106,7 +106,7 @@ public function seeTranslationAdminInCss(string $id, string $css, string $domain
* @param array $parameters
* @param \Facebook\WebDriver\WebDriverBy|\Facebook\WebDriver\WebDriverElement|null $contextSelector
*/
- public function clickByTranslationAdmin(string $id, string $domain = 'messages', array $parameters = [], $contextSelector = null): void
+ public function clickByTranslationAdmin(string $id, string $domain = 'messages', array $parameters = [], $contextSelector = null)
{
$translatedMessage = t($id, $parameters, $domain, $this->getAdminLocale());
$this->webDriver->clickByText(strip_tags($translatedMessage), $contextSelector);
@@ -118,7 +118,7 @@ public function clickByTranslationAdmin(string $id, string $domain = 'messages',
* @param array $parameters
* @param \Facebook\WebDriver\WebDriverBy|\Facebook\WebDriver\WebDriverElement|null $contextSelector
*/
- public function clickByTranslationFrontend(string $id, string $domain = 'messages', array $parameters = [], $contextSelector = null): void
+ public function clickByTranslationFrontend(string $id, string $domain = 'messages', array $parameters = [], $contextSelector = null)
{
$translatedMessage = t($id, $parameters, $domain, $this->getFrontendLocale());
$this->webDriver->clickByText(strip_tags($translatedMessage), $contextSelector);
@@ -129,7 +129,7 @@ public function clickByTranslationFrontend(string $id, string $domain = 'message
* @param string $domain
* @param array $parameters
*/
- public function checkOptionByLabelTranslationFrontend(string $id, string $domain = 'messages', array $parameters = []): void
+ public function checkOptionByLabelTranslationFrontend(string $id, string $domain = 'messages', array $parameters = [])
{
$translatedMessage = t($id, $parameters, $domain, $this->getFrontendLocale());
$this->webDriver->checkOptionByLabel($translatedMessage);
diff --git a/tests/App/Test/Codeception/Module/StrictWebDriver.php b/tests/App/Test/Codeception/Module/StrictWebDriver.php
index a0e9f1f2e2..f0f36b0354 100644
--- a/tests/App/Test/Codeception/Module/StrictWebDriver.php
+++ b/tests/App/Test/Codeception/Module/StrictWebDriver.php
@@ -130,7 +130,7 @@ public function clickByCss($css)
*/
public function clickByElement(WebDriverElement $element)
{
- $element->click();
+ return $element->click();
}
/**
diff --git a/tests/App/Test/Codeception/_bootstrap.php b/tests/App/Test/Codeception/_bootstrap.php
deleted file mode 100644
index 88e6674a1f..0000000000
--- a/tests/App/Test/Codeception/_bootstrap.php
+++ /dev/null
@@ -1,5 +0,0 @@
-domain->switchDomainById(Domain::FIRST_DOMAIN_ID);
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
$this->setUpDomain();
-
- $this->domainRouterFactory = $this->getContainer()->get(DomainRouterFactory::class);
- $this->priceConverter = $this->getContainer()->get(PriceConverter::class);
}
/**
@@ -57,13 +57,15 @@ protected function setUp()
* @param string $username
* @param string $password
* @param array $kernelOptions
+ * @param array $clientOptions
* @return \Symfony\Bundle\FrameworkBundle\Client
*/
- protected function getClient(
+ protected function findClient(
$createNew = false,
$username = null,
$password = null,
- $kernelOptions = []
+ $kernelOptions = [],
+ $clientOptions = []
) {
$defaultKernelOptions = [
'environment' => EnvironmentType::TEST,
@@ -73,10 +75,10 @@ protected function getClient(
$kernelOptions = array_replace($defaultKernelOptions, $kernelOptions);
if ($createNew) {
- $this->client = $this->createClient($kernelOptions);
+ $this->client = $this->createClient($kernelOptions, $clientOptions);
$this->setUpDomain();
} elseif (!isset($this->client)) {
- $this->client = $this->createClient($kernelOptions);
+ $this->client = $this->createClient($kernelOptions, $clientOptions);
}
if ($username !== null) {
@@ -94,7 +96,7 @@ protected function getClient(
*/
protected function getContainer()
{
- return $this->getClient()->getContainer();
+ return $this->findClient()->getContainer();
}
/**
@@ -103,11 +105,7 @@ protected function getContainer()
*/
protected function getReference($referenceName)
{
- /** @var \Shopsys\FrameworkBundle\Component\DataFixture\PersistentReferenceFacade $persistentReferenceFacade */
- $persistentReferenceFacade = $this->getContainer()
- ->get(PersistentReferenceFacade::class);
-
- return $persistentReferenceFacade->getReference($referenceName);
+ return $this->persistentReferenceFacade->getReference($referenceName);
}
/**
@@ -125,11 +123,7 @@ public function createContainer(): ContainerInterface
*/
protected function getReferenceForDomain(string $referenceName, int $domainId)
{
- /** @var \Shopsys\FrameworkBundle\Component\DataFixture\PersistentReferenceFacade $persistentReferenceFacade */
- $persistentReferenceFacade = $this->getContainer()
- ->get(PersistentReferenceFacade::class);
-
- return $persistentReferenceFacade->getReferenceForDomain($referenceName, $domainId);
+ return $this->persistentReferenceFacade->getReferenceForDomain($referenceName, $domainId);
}
protected function skipTestIfFirstDomainIsNotInEnglish()
@@ -155,7 +149,8 @@ protected function getFirstDomainLocale(): string
*/
protected function getLocalizedPathOnFirstDomainByRouteName(string $routeName, array $parameters = []): string
{
- $router = $this->domainRouterFactory->getRouter(Domain::FIRST_DOMAIN_ID);
+ $domainRouterFactory = $this->getContainer()->get(DomainRouterFactory::class);
+ $router = $domainRouterFactory->getRouter(Domain::FIRST_DOMAIN_ID);
return $router->generate($routeName, $parameters, UrlGeneratorInterface::ABSOLUTE_URL);
}
diff --git a/tests/App/Test/TransactionFunctionalTestCase.php b/tests/App/Test/TransactionFunctionalTestCase.php
index 95123f327e..2e493d18de 100644
--- a/tests/App/Test/TransactionFunctionalTestCase.php
+++ b/tests/App/Test/TransactionFunctionalTestCase.php
@@ -4,26 +4,29 @@
namespace Tests\App\Test;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
+
abstract class TransactionFunctionalTestCase extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
- * @return \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
+ * @var \Shopsys\FrameworkBundle\Component\EntityExtension\EntityManagerDecorator
+ * @inject
*/
- protected function getEntityManager()
- {
- return $this->getContainer()->get('doctrine.orm.entity_manager');
- }
+ protected $em;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
- $this->getEntityManager()->beginTransaction();
+ $this->em->beginTransaction();
+ $this->em->getConnection()->setAutoCommit(false);
}
- protected function tearDown()
+ protected function tearDown(): void
{
- $this->getEntityManager()->rollback();
+ $this->em->rollback();
parent::tearDown();
}
diff --git a/tests/App/Unit/Form/Front/Order/PersonalInfoFormTypeTest.php b/tests/App/Unit/Form/Front/Order/PersonalInfoFormTypeTest.php
index 36e9913c1c..69a5983b47 100644
--- a/tests/App/Unit/Form/Front/Order/PersonalInfoFormTypeTest.php
+++ b/tests/App/Unit/Form/Front/Order/PersonalInfoFormTypeTest.php
@@ -111,7 +111,7 @@ protected function getExtensions(): array
];
}
- protected function setUp()
+ protected function setUp(): void
{
$countryMock = $this->createMock(Country::class);
$countryMock->method('getId')->willReturn(1);
diff --git a/tests/FrontendApiBundle/Test/GraphQlTestCase.php b/tests/FrontendApiBundle/Test/GraphQlTestCase.php
index 7cee96fb40..cf3fbb1f9b 100644
--- a/tests/FrontendApiBundle/Test/GraphQlTestCase.php
+++ b/tests/FrontendApiBundle/Test/GraphQlTestCase.php
@@ -23,7 +23,7 @@ abstract class GraphQlTestCase extends FunctionalTestCase
protected function setUp(): void
{
- $this->client = $this->getClient(true);
+ $this->client = $this->findClient(true);
if (!$this->enabledOnCurrentDomainChecker->isEnabledOnCurrentDomain()) {
$this->markTestSkipped('Frontend API disabled on domain');
@@ -72,9 +72,9 @@ protected function getResponseContentForQuery(string $query, array $variables =
/**
* @param string $query
* @param array $variables
- * @return \Symfony\Component\HttpFoundation\Response|null
+ * @return \Symfony\Component\HttpFoundation\Response
*/
- private function getResponseForQuery(string $query, array $variables): ?Response
+ private function getResponseForQuery(string $query, array $variables): Response
{
$path = $this->getLocalizedPathOnFirstDomainByRouteName('overblog_graphql_endpoint');
diff --git a/tests/ReadModelBundle/Functional/Product/Listed/ListedProductViewFacadeTest.php b/tests/ReadModelBundle/Functional/Product/Listed/ListedProductViewFacadeTest.php
index d175ab7935..ce9f26e76f 100644
--- a/tests/ReadModelBundle/Functional/Product/Listed/ListedProductViewFacadeTest.php
+++ b/tests/ReadModelBundle/Functional/Product/Listed/ListedProductViewFacadeTest.php
@@ -8,9 +8,12 @@
use Shopsys\FrameworkBundle\Model\Product\Listing\ProductListOrderingConfig;
use Shopsys\ReadModelBundle\Product\Listed\ListedProductView;
use Tests\App\Test\FunctionalTestCase;
+use Zalas\Injector\PHPUnit\Symfony\TestCase\SymfonyTestContainer;
class ListedProductViewFacadeTest extends FunctionalTestCase
{
+ use SymfonyTestContainer;
+
/**
* @var \Shopsys\ReadModelBundle\Product\Listed\ListedProductViewFacadeInterface
* @inject
diff --git a/tests/ReadModelBundle/Functional/Twig/ImageExtensionTest.php b/tests/ReadModelBundle/Functional/Twig/ImageExtensionTest.php
index ac2510c0e3..409c128aa2 100644
--- a/tests/ReadModelBundle/Functional/Twig/ImageExtensionTest.php
+++ b/tests/ReadModelBundle/Functional/Twig/ImageExtensionTest.php
@@ -139,7 +139,7 @@ private function createImageExtension(
?ImageFacade $imageFacade = null,
bool $enableLazyLoad = false
): ImageExtension {
- $templating = $this->getContainer()->get('templating');
+ $templating = $this->getContainer()->get('twig');
$imageFacade = $imageFacade ?: $this->imageFacade;
return new ImageExtension($frontDesignImageUrlPrefix, $this->domain, $this->imageLocator, $imageFacade, $templating, $enableLazyLoad);
diff --git a/yaml-standards.yaml b/yaml-standards.yaml
new file mode 100644
index 0000000000..1e3a6ac7f1
--- /dev/null
+++ b/yaml-standards.yaml
@@ -0,0 +1,11 @@
+- pathsToCheck:
+ - .
+ excludedPaths:
+ - ./vendor
+ - ./node_modules
+ - ./config/domains_urls.yml
+ - ./config/oauth2/parameters_oauth.yml.dist
+ checkers:
+ - pathToChecker: YamlStandards\Model\YamlIndent\YamlIndentChecker
+ parameters:
+ { indents: 4, indentsCommentsWithoutParent: default }