From b826392efe3dd29353ec639c12c7ce3dc05cd104 Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Wed, 19 Oct 2022 22:59:19 -0500 Subject: [PATCH] refactor: change cache key names --- src/Service/Dce/SystemDce.php | 4 ++-- src/Service/Nic/SystemNic.php | 2 +- tests/unit/Service/Dce/SystemDceTest.php | 16 ++++++++-------- tests/unit/Service/Nic/SystemNicTest.php | 10 +++++----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Service/Dce/SystemDce.php b/src/Service/Dce/SystemDce.php index c244455..9d0f42f 100644 --- a/src/Service/Dce/SystemDce.php +++ b/src/Service/Dce/SystemDce.php @@ -43,12 +43,12 @@ final class SystemDce implements Dce /** * Key to use when caching the GID value in a PSR-16 cache instance */ - private const GID_CACHE_KEY = '__ramsey_identifier_27a5'; + private const GID_CACHE_KEY = '__ramsey_id_gid'; /** * Key to use when caching the UID value in a PSR-16 cache instance */ - private const UID_CACHE_KEY = '__ramsey_identifier_690f'; + private const UID_CACHE_KEY = '__ramsey_id_uid'; /** * @var int<0, max> | null diff --git a/src/Service/Nic/SystemNic.php b/src/Service/Nic/SystemNic.php index cad2e40..d631f11 100644 --- a/src/Service/Nic/SystemNic.php +++ b/src/Service/Nic/SystemNic.php @@ -45,7 +45,7 @@ final class SystemNic implements Nic /** * Key to use when caching the address value in a PSR-16 cache instance */ - private const CACHE_KEY = '__ramsey_identifier_64f4'; + private const CACHE_KEY = '__ramsey_id_system_addr'; /** * The system address, stored statically for better performance diff --git a/tests/unit/Service/Dce/SystemDceTest.php b/tests/unit/Service/Dce/SystemDceTest.php index 4814385..3a5ee03 100644 --- a/tests/unit/Service/Dce/SystemDceTest.php +++ b/tests/unit/Service/Dce/SystemDceTest.php @@ -51,7 +51,7 @@ public function testGroupId(): void public function testGroupIdFromCache(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_27a5')->andReturn(5001); + $cache->expects('get')->with('__ramsey_id_gid')->andReturn(5001); $dce = new SystemDce(cache: $cache); @@ -68,8 +68,8 @@ public function testGroupIdFromCache(): void public function testGroupIdFromCacheSetsIdentifierOnCache(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_27a5')->andReturnNull(); - $cache->expects('set')->with('__ramsey_identifier_27a5', new IsInteger())->andReturnTrue(); + $cache->expects('get')->with('__ramsey_id_gid')->andReturnNull(); + $cache->expects('set')->with('__ramsey_id_gid', new IsInteger())->andReturnTrue(); $dce = new SystemDce(cache: $cache); $groupId = $dce->groupId(); @@ -87,7 +87,7 @@ public function testGroupIdFromCacheSetsIdentifierOnCache(): void public function testGroupIdThrowsExceptionWhenIdentifierNotFound(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_27a5')->andReturn(-1); + $cache->expects('get')->with('__ramsey_id_gid')->andReturn(-1); $dce = new SystemDce(cache: $cache); @@ -256,7 +256,7 @@ public function testUserId(): void public function testUserIdFromCache(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_690f')->andReturn(6001); + $cache->expects('get')->with('__ramsey_id_uid')->andReturn(6001); $dce = new SystemDce(cache: $cache); @@ -273,8 +273,8 @@ public function testUserIdFromCache(): void public function testUserIdFromCacheSetsIdentifierOnCache(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_690f')->andReturnNull(); - $cache->expects('set')->with('__ramsey_identifier_690f', new IsInteger())->andReturnTrue(); + $cache->expects('get')->with('__ramsey_id_uid')->andReturnNull(); + $cache->expects('set')->with('__ramsey_id_uid', new IsInteger())->andReturnTrue(); $dce = new SystemDce(cache: $cache); $userId = $dce->userId(); @@ -292,7 +292,7 @@ public function testUserIdFromCacheSetsIdentifierOnCache(): void public function testUserIdThrowsExceptionWhenIdentifierNotFound(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_690f')->andReturn(-1); + $cache->expects('get')->with('__ramsey_id_uid')->andReturn(-1); $dce = new SystemDce(cache: $cache); diff --git a/tests/unit/Service/Nic/SystemNicTest.php b/tests/unit/Service/Nic/SystemNicTest.php index 1722b63..2e43fce 100644 --- a/tests/unit/Service/Nic/SystemNicTest.php +++ b/tests/unit/Service/Nic/SystemNicTest.php @@ -42,7 +42,7 @@ public function testAddress(): void public function testAddressFoundInCache(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_64f4')->andReturn('aabbccddeeff'); + $cache->expects('get')->with('__ramsey_id_system_addr')->andReturn('aabbccddeeff'); $nic = new SystemNic($cache); @@ -59,10 +59,10 @@ public function testAddressFoundInCache(): void public function testAddressStoredInCache(): void { $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_64f4')->andReturnNull(); + $cache->expects('get')->with('__ramsey_id_system_addr')->andReturnNull(); $cache ->expects('set') - ->with('__ramsey_identifier_64f4', Mockery::pattern('/^[0-9a-f]{12}$/i')) + ->with('__ramsey_id_system_addr', Mockery::pattern('/^[0-9a-f]{12}$/i')) ->andReturnTrue(); $nic = new SystemNic($cache); @@ -353,10 +353,10 @@ public function testAddressUsesRandomNicIfAddressNotFoundWithCache(): void $os->expects('run')->with('netstat -ie')->andReturn($netstat); $cache = $this->mockery(CacheInterface::class); - $cache->expects('get')->with('__ramsey_identifier_64f4')->andReturn(''); + $cache->expects('get')->with('__ramsey_id_system_addr')->andReturn(''); $cache ->expects('set') - ->with('__ramsey_identifier_64f4', Mockery::pattern('/^[0-9a-f]{12}$/i')) + ->with('__ramsey_id_system_addr', Mockery::pattern('/^[0-9a-f]{12}$/i')) ->andReturnTrue(); $nic = new SystemNic($cache, $os);