-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce dynamic shop pools based on shop id
- Loading branch information
Showing
9 changed files
with
90 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool; | ||
|
||
class ShopPoolName | ||
{ | ||
private static string $namePrefix = 'oxid_shop_pool_'; | ||
|
||
public static function get(int $shopId): string | ||
{ | ||
return static::$namePrefix . $shopId; | ||
} | ||
|
||
public static function getAll(array $shopIds): array | ||
{ | ||
return array_map( | ||
static fn($id) => static::$namePrefix . $id, | ||
$shopIds | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/Unit/Internal/Framework/Cache/Pool/ShopPoolNameTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Framework\Cache\Pool; | ||
|
||
use OxidEsales\EshopCommunity\Internal\Framework\Cache\Pool\ShopPoolName; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[Group('cache')] | ||
class ShopPoolNameTest extends TestCase | ||
{ | ||
public function testGetPoolName(): void | ||
{ | ||
$shopId = 1; | ||
$this->assertSame( | ||
'oxid_shop_pool_' . $shopId, | ||
ShopPoolName::get($shopId) | ||
); | ||
} | ||
|
||
public function testGetAllPoolName(): void | ||
{ | ||
$this->assertSame( | ||
['oxid_shop_pool_1', 'oxid_shop_pool_2', 'oxid_shop_pool_3', 'oxid_shop_pool_4', 'oxid_shop_pool_5'], | ||
ShopPoolName::getAll([1, 2, 3, 4, 5,]) | ||
); | ||
} | ||
} |