Skip to content

Commit

Permalink
feat(Testing): Add test snapshots for OXID PE and OXID EE (#22)
Browse files Browse the repository at this point in the history
* Add snapshots for OXID PE and OXID EE

* Refactor services

* Remove blank line
  • Loading branch information
kyoya-de authored Apr 21, 2023
1 parent 08886c4 commit 1a7cc3b
Show file tree
Hide file tree
Showing 116 changed files with 92,147 additions and 438 deletions.
69 changes: 43 additions & 26 deletions services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@ services:
public: false
autowire: true
autoconfigure: true
bind:
OxidEsales\Eshop\Core\Language $language: "@makaira.oxid.language"
Doctrine\DBAL\Connection $connection: "@makaira.oxid.database"
OxidEsales\Eshop\Core\UtilsObject $utilsObject: "@makaira.oxid.utils_object"
OxidEsales\Eshop\Application\Model\SeoEncoderArticle $seoEncoderArticle: "@makaira.oxid.seo_encoder_article"
OxidEsales\Eshop\Application\Model\SeoEncoderCategory $seoEncoderCategory: "@makaira.oxid.seo_encoder_category"
OxidEsales\Eshop\Application\Model\SeoEncoderManufacturer $seoEncoderManufacturer: "@makaira.oxid.seo_encoder_manufacturer"
OxidEsales\Eshop\Core\Session $session: "@makaira.oxid.session"
OxidEsales\Eshop\Application\Controller\FrontendController $frontendController: "@makaira.oxid.frontend_controller"
OxidEsales\Eshop\Core\TableViewNameGenerator $viewNameGenerator: "@makaira.oxid.table_view_name_generator"

Makaira\OxidConnectEssential\:
resource: './src/'
exclude: './src/{Controller,Domain,Event,Oxid,Type,Exception,Core}/*'

OxidEsales\Eshop\Core\TableViewNameGenerator: ~

Makaira\OxidConnectEssential\Command\CleanUpCommand:
tags:
- { name: 'console.command', command: 'makaira:cleanup' }
Expand All @@ -35,7 +43,7 @@ services:
public: true
bind:
$repositories: !tagged makaira_connect_essential.repository
$parentsPurchasable: '@=service("OxidEsales\\Eshop\\Core\\Config").getShopConfVar("blVariantParentBuyable")'
$parentsPurchasable: '@=service("makaira.oxid.config").getShopConfVar("blVariantParentBuyable")'

Makaira\OxidConnectEssential\Rpc\RpcService:
public: true
Expand Down Expand Up @@ -194,13 +202,13 @@ services:

Makaira\OxidConnectEssential\Modifier\Common\LongDescriptionModifier:
bind:
$parseLongDesc: '@=service("OxidEsales\\Eshop\\Core\\Config").getShopConfVar("bl_perfParseLongDescinSmarty")'
$parseLongDesc: '@=service("makaira.oxid.config").getShopConfVar("bl_perfParseLongDescinSmarty")'

Makaira\OxidConnectEssential\Modifier\Common\PriceModifier:
bind:
$isNetto: '@=service("OxidEsales\\Eshop\\Core\\Config").getShopConfVar("blEnterNetPrice")'
$showNetto: '@=service("OxidEsales\\Eshop\\Core\\Config").getShopConfVar("blShowNetPrice")'
$defaultVAT: '@=service("OxidEsales\\Eshop\\Core\\Config").getShopConfVar("dDefaultVAT")'
$isNetto: '@=service("makaira.oxid.config").getShopConfVar("blEnterNetPrice")'
$showNetto: '@=service("makaira.oxid.config").getShopConfVar("blShowNetPrice")'
$defaultVAT: '@=service("makaira.oxid.config").getShopConfVar("dDefaultVAT")'
tags:
- { name: 'makaira.importer.modifier.product', priority: 1000 }
- { name: 'makaira.importer.modifier.variant', priority: 1000 }
Expand All @@ -215,7 +223,7 @@ services:
Makaira\OxidConnectEssential\Modifier\Common\AbstractShopModifier:
abstract: true
bind:
$isMultiShop: '@=service("OxidEsales\\Eshop\\Core\\Config").isMall()'
$isMultiShop: '@=service("makaira.oxid.config").isMall()'

Makaira\OxidConnectEssential\Modifier\Product\ShopModifier:
public: false
Expand Down Expand Up @@ -244,7 +252,7 @@ services:

Makaira\OxidConnectEssential\Modifier\Common\StockModifier:
bind:
$useStock: '@=service("OxidEsales\\Eshop\\Core\\Config").getShopConfVar("blUseStock")'
$useStock: '@=service("makaira.oxid.config").getShopConfVar("blUseStock")'
tags:
- { name: 'makaira.importer.modifier.product', priority: 1000 }
- { name: 'makaira.importer.modifier.variant', priority: 1000 }
Expand Down Expand Up @@ -275,48 +283,57 @@ services:

### Helper ###

Doctrine\DBAL\Driver\Connection:
alias: Doctrine\DBAL\Connection

Doctrine\DBAL\Connection:
makaira.oxid.database:
class: Doctrine\DBAL\Connection
factory: ['@OxidEsales\EshopCommunity\Internal\Framework\Database\ConnectionProviderInterface', 'get']

OxidEsales\Eshop\Core\Language:
makaira.oxid.language:
class: OxidEsales\Eshop\Core\Language
public: true
factory: ['OxidEsales\Eshop\Core\Registry', 'getLang']

OxidEsales\Eshop\Core\Config:
makaira.oxid.config:
class: OxidEsales\Eshop\Core\Config
public: true
factory: ['OxidEsales\Eshop\Core\Registry', 'getConfig']

OxidEsales\Eshop\Core\UtilsObject:
makaira.oxid.utils_object:
class: OxidEsales\Eshop\Core\UtilsObject
public: true
factory: ['OxidEsales\Eshop\Core\UtilsObject', 'getInstance']

OxidEsales\Eshop\Core\Session:
makaira.oxid.session:
class: OxidEsales\Eshop\Core\Session
public: true
factory: ['OxidEsales\Eshop\Core\Registry', 'getSession']

OxidEsales\Eshop\Application\Controller\FrontendController:
makaira.oxid.frontend_controller:
class: OxidEsales\Eshop\Application\Controller\FrontendController
public: true
factory: ['@OxidEsales\Eshop\Core\UtilsObject', 'oxNew']
factory: ['@makaira.oxid.utils_object', 'oxNew']
arguments: ['OxidEsales\Eshop\Application\Controller\FrontendController']

OxidEsales\Eshop\Application\Model\SeoEncoderCategory:
makaira.oxid.seo_encoder_category:
class: OxidEsales\Eshop\Application\Model\SeoEncoderCategory
public: true
factory: ['@OxidEsales\Eshop\Core\UtilsObject', 'oxNew']
factory: ['@makaira.oxid.utils_object', 'oxNew']
arguments: ['OxidEsales\Eshop\Application\Model\SeoEncoderCategory']

OxidEsales\Eshop\Application\Model\SeoEncoderManufacturer:
makaira.oxid.seo_encoder_manufacturer:
class: OxidEsales\Eshop\Application\Model\SeoEncoderManufacturer
public: true
factory: ['@OxidEsales\Eshop\Core\UtilsObject', 'oxNew']
factory: ['@makaira.oxid.utils_object', 'oxNew']
arguments: ['OxidEsales\Eshop\Application\Model\SeoEncoderManufacturer']

OxidEsales\Eshop\Application\Model\SeoEncoderArticle:
makaira.oxid.seo_encoder_article:
class: OxidEsales\Eshop\Application\Model\SeoEncoderArticle
public: true
factory: ['@OxidEsales\Eshop\Core\UtilsObject', 'oxNew']
factory: ['@makaira.oxid.utils_object', 'oxNew']
arguments: ['OxidEsales\Eshop\Application\Model\SeoEncoderArticle']

makaira.oxid.table_view_name_generator:
class: OxidEsales\Eshop\Core\TableViewNameGenerator

Makaira\OxidConnectEssential\Service\UserService:
public: true
class: Makaira\OxidConnectEssential\Service\UserService
Expand All @@ -325,7 +342,7 @@ services:
public: true
class: Makaira\OxidConnectEssential\Service\CartService
bind:
$basket: '@=service("OxidEsales\\Eshop\\Core\\Session").getBasket()'
$basket: '@=service("makaira.oxid.session").getBasket()'

Makaira\OxidConnectEssential\Service\ReviewService:
public: true
Expand Down
5 changes: 1 addition & 4 deletions src/Command/CleanUpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
*/
class CleanUpCommand extends Command
{
private RevisionRepository $revisionRepository;

public function __construct(RevisionRepository $revisionRepository)
public function __construct(private RevisionRepository $revisionRepository)
{
$this->revisionRepository = $revisionRepository;
parent::__construct('makaira:cleanup');
}

Expand Down
11 changes: 1 addition & 10 deletions src/Command/TouchAllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,12 @@
*/
class TouchAllCommand extends Command
{
/**
* @var iterable<AbstractRepository>
*/
private iterable $repositories;

private RevisionRepository $revisionRepository;

/**
* @param iterable<AbstractRepository> $repositories
* @param RevisionRepository $revisionRepository
*/
public function __construct(iterable $repositories, RevisionRepository $revisionRepository)
public function __construct(private iterable $repositories, private RevisionRepository $revisionRepository)
{
$this->revisionRepository = $revisionRepository;
$this->repositories = $repositories;
parent::__construct('makaira:touch-all');
}

Expand Down
20 changes: 4 additions & 16 deletions src/Domain/Revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,18 @@ class Revision
public const TYPE_CATEGORY = 'category';
public const TYPE_MANUFACTURER = 'manufacturer';

public string $type;

public string $objectId;

public ?DateTimeInterface $changed = null;

public ?int $revision = null;

/**
* @param string $type
* @param string $objectId
* @param DateTimeInterface|null $changed
* @param int|null $revision
*/
public function __construct(
string $type,
string $objectId,
?DateTimeInterface $changed = null,
?int $revision = null
public string $type,
public string $objectId,
public ?DateTimeInterface $changed = null,
public ?int $revision = null
) {
$this->revision = $revision;
$this->changed = $changed;
$this->objectId = $objectId;
$this->type = $type;
if (null === $changed) {
$this->changed = new DateTimeImmutable();
}
Expand Down
5 changes: 1 addition & 4 deletions src/Entity/RevisionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@
*/
class RevisionRepository
{
private Connection $connection;

private ?Statement $fetchParentId = null;

private ?Statement $insertRevision = null;

/**
* @param Connection $connection
*/
public function __construct(Connection $connection)
public function __construct(private Connection $connection)
{
$this->connection = $connection;
}

/**
Expand Down
10 changes: 2 additions & 8 deletions src/Event/DatabaseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,14 @@ class DatabaseSubscriber implements EventSubscriberInterface
*/
private array $revisions = [];

private ModelDataExtractor $dataExtractor;

private RevisionRepository $revisionRepository;

/**
* @param ModelDataExtractor $dataExtractor
* @param RevisionRepository $revisionRepository
*/
public function __construct(
ModelDataExtractor $dataExtractor,
RevisionRepository $revisionRepository
private ModelDataExtractor $dataExtractor,
private RevisionRepository $revisionRepository
) {
$this->revisionRepository = $revisionRepository;
$this->dataExtractor = $dataExtractor;
}

/**
Expand Down
8 changes: 1 addition & 7 deletions src/Event/ModifierCollectEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@

class ModifierCollectEvent extends Event
{
/**
* @var ModifierList
*/
public ModifierList $modifierList;

public function __construct(ModifierList $modifierList)
public function __construct(private ModifierList $modifierList)
{
$this->modifierList = $modifierList;
}

public function addModifier(Modifier $modifier): void
Expand Down
8 changes: 1 addition & 7 deletions src/Event/RepositoryCollectEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,8 @@

class RepositoryCollectEvent extends Event
{
/**
* @var Repository
*/
public Repository $repository;

public function __construct(Repository $repository)
public function __construct(private Repository $repository)
{
$this->repository = $repository;
}

public function addRepository(AbstractRepository $repository): void
Expand Down
10 changes: 2 additions & 8 deletions src/Modifier/Category/HierarchyModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,8 @@ class HierarchyModifier extends Modifier
ORDER BY oc.OXLEFT;
";

private Connection $database;

private TableTranslator $tableTranslator;

public function __construct(Connection $database, TableTranslator $tableTranslator)
public function __construct(private Connection $connection, private TableTranslator $tableTranslator)
{
$this->database = $database;
$this->tableTranslator = $tableTranslator;
}

/**
Expand All @@ -56,7 +50,7 @@ public function __construct(Connection $database, TableTranslator $tableTranslat
public function apply(Type $category): Category
{
/** @var Result $resultStatement */
$resultStatement = $this->database->executeQuery(
$resultStatement = $this->connection->executeQuery(
$this->tableTranslator->translate($this->selectQuery),
[
'left' => $category->additionalData['OXLEFT'],
Expand Down
11 changes: 5 additions & 6 deletions src/Modifier/Category/SubcategoriesModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@

namespace Makaira\OxidConnectEssential\Modifier\Category;

use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Doctrine\DBAL\Exception as DBALException;
use Makaira\OxidConnectEssential\Modifier;
use Makaira\OxidConnectEssential\Type;
use Makaira\OxidConnectEssential\Utils\CategoryInheritance;
use Makaira\OxidConnectEssential\Type\Category\Category;

class SubcategoriesModifier extends Modifier
{
private CategoryInheritance $categoryInheritance;

public function __construct(CategoryInheritance $categoryInheritance)
public function __construct(private CategoryInheritance $categoryInheritance)
{
$this->categoryInheritance = $categoryInheritance;
}

/**
* @param Category $category
*
* @return Category
* @throws \Doctrine\DBAL\Driver\Exception
* @throws \Doctrine\DBAL\Exception
* @throws DBALDriverException
* @throws DBALException
*/
public function apply(Type $category): Category
{
Expand Down
13 changes: 5 additions & 8 deletions src/Modifier/Category/UrlModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@

class UrlModifier extends AbstractUrlModifier
{
private SeoEncoderCategory $encoder;

/**
* @param SeoEncoderCategory $encoder
* @param Language $oxLang
* @param SeoEncoderCategory $seoEncoderCategory
* @param Language $language
*/
public function __construct(SeoEncoderCategory $encoder, Language $oxLang)
public function __construct(private SeoEncoderCategory $seoEncoderCategory, Language $language)
{
$this->encoder = $encoder;
parent::__construct($oxLang);
parent::__construct($language);
}

/**
Expand All @@ -43,7 +40,7 @@ protected function getUrl(Type $type, BaseModel $model, int $languageId): string
$url = '';

if ($model instanceof Category) {
$url = $this->encoder->getCategoryUri($model, $languageId);
$url = $this->seoEncoderCategory->getCategoryUri($model, $languageId);
}

return $url;
Expand Down
Loading

0 comments on commit 1a7cc3b

Please sign in to comment.