Skip to content

Commit

Permalink
feat: improve services building
Browse files Browse the repository at this point in the history
  • Loading branch information
hschoenenberger committed Feb 8, 2024
1 parent f27ccd1 commit fc7232c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tests/Feature/Api/v1/ShopLinkAccount/DeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function setUp()
parent::setUp(); // TODO: Change the autogenerated stub

$this->buildServices([
'linkShop' => LinkShop::class,
'shopSession' => ShopSession::class,
'ownerSession' => OwnerSession::class,
'session' => \PrestaShop\Module\PsAccounts\Account\Session\ShopSession::class
LinkShop::class,
ShopSession::class,
OwnerSession::class,
['session' => \PrestaShop\Module\PsAccounts\Account\Session\ShopSession::class],
]);
}

Expand Down
12 changes: 9 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,15 @@ public function rollback()
*/
protected function buildServices(array $services = [])
{
array_walk($services, function ($class, $property) {
echo $class;
$this->$property = $this->module->getService($class);
//return lcfirst(preg_replace('/^.*\\\\/', '', static::class));
array_walk($services, function ($class) {
if (is_array($class)) {
$propName = array_keys($class)[0];
$class = $class[$propName];
} else {
$propName = lcfirst(preg_replace('/^.*\\\\/', '', $class));
}
$this->$propName = $this->module->getService($class);
});
}

Expand Down

0 comments on commit fc7232c

Please sign in to comment.