diff --git a/src/Services/ReadOnlyCacheService.php b/src/Services/ReadOnlyCacheService.php index 60fd2957..5fc1c3eb 100644 --- a/src/Services/ReadOnlyCacheService.php +++ b/src/Services/ReadOnlyCacheService.php @@ -10,6 +10,7 @@ */ class ReadOnlyCacheService { + use Injectable; private $enabled = false; diff --git a/tests/php/Services/ReadOnlyCacheServiceTest.php b/tests/php/Services/ReadOnlyCacheServiceTest.php new file mode 100644 index 00000000..08c38593 --- /dev/null +++ b/tests/php/Services/ReadOnlyCacheServiceTest.php @@ -0,0 +1,38 @@ +assertFalse($service->getEnabled()); + $service->setEnabled(true); + $this->assertTrue($service->getEnabled()); + } + + public function testGetSetHasValue() + { + $service = ReadOnlyCacheService::singleton(); + $this->assertFalse($service->hasValue(['A', 'B'], ['1', '2'])); + $service->setValue(['A', 'B'], ['1', '2'], 'xyz'); + $this->assertTrue($service->hasValue(['A', 'B'], ['1', '2'])); + $this->assertEquals('xyz', $service->getValue(['A', 'B'], ['1', '2'])); + } + + public function testReset() + { + $service = ReadOnlyCacheService::singleton(); + $service->setValue(['A', 'B'], ['1', '2'], 'xyz'); + $service->setValue(['C', 'D'], ['3', '4'], 'wvu'); + $this->assertTrue($service->hasValue(['A', 'B'], ['1', '2'])); + $service->reset(['A', 'B']); + $this->assertFalse($service->hasValue(['A', 'B'], ['1', '2'])); + $this->assertTrue($service->hasValue(['C', 'D'], ['3', '4'])); + $service->reset(); + $this->assertFalse($service->hasValue(['C', 'D'], ['3', '4'])); + } +}