*/ class ConfigSetsTest extends TestCase { /** * @var ConfigSets */ protected $configurable; /** * Configure registry instance */ protected function setUp(): void { $this->configurable = new ConfigurableTestSample([ 'handlers' => [ 'handler_1_name' => 'handler_1', 'handler_2_name' => 'handler_2', ], 'listeners' => [ 'listener_1_name' => 'listener_1', 'listener_2_name' => 'listener_2', ], 'key' => 'val' ]); } public function testHashGet() { $this->assertEquals('handler_1', $this->configurable->hashGet('handlers', 'handler_1_name')); $this->assertEquals(null, $this->configurable->hashGet('foo', 'bar')); } public function testHashSet() { $this->configurable->hashSet('handlers', 'handler_3_name', 'handler_3'); $this->assertEquals('handler_3', $this->configurable->hashGet('handlers', 'handler_3_name')); $this->configurable->hashSet('handlers', 'handler_2_name', 'handler_4'); $this->assertEquals('handler_4', $this->configurable->hashGet('handlers', 'handler_2_name')); $this->configurable->hashSet('foo', 'bar', 'baz'); $this->assertEquals('baz', $this->configurable->hashGet('foo', 'bar')); } public function testHashSetException() { $this->expectException(common_exception_InconsistentData::class); $this->configurable->hashSet('key', 'bar', 'baz'); } public function testHashRemove() { $this->configurable->hashRemove('handlers', 'handler_1_name'); $this->assertEquals(null, $this->configurable->hashGet('handlers', 'handler_1_name')); $this->assertFalse($this->configurable->hashRemove('handlers', 'handler_1_name')); } } /** * Class ConfigurableTestSample * @package oat\generis\test\config */ class ConfigurableTestSample extends ConfigurableService { use ConfigSets; }