assertInternalType('object', $obj); } catch (\Exception $e) { $this->assertContains('Must be initialized ', $e->getMessage()); } } public function testGetParameters() { $obj = new Config(); $params = $obj->getParameters(); $this->assertCount(5, $params); $this->assertEquals($params['legacy'], false); $this->assertEquals($params['ssl'], false); $this->assertEquals($params['timeout'], 10); $this->assertEquals($params['attempts'], 10); $this->assertEquals($params['delay'], 1); } public function testGetParameters2() { $obj = new Config(['timeout' => 100]); $params = $obj->getParameters(); $this->assertCount(5, $params); $this->assertEquals($params['timeout'], 100); } public function testSet() { $obj = new Config(); $obj->set('timeout', 111); $params = $obj->getParameters(); $this->assertEquals($params['timeout'], 111); } public function testSetArr() { $obj = new Config([ 'timeout' => 111 ]); $params = $obj->getParameters(); $this->assertEquals($params['timeout'], 111); } public function testDelete() { $obj = new Config(); $obj->delete('timeout'); $params = $obj->getParameters(); $this->assertArrayNotHasKey('timeout', $params); } public function testDeleteEx() { $this->expectException(ConfigException::class); $obj = new Config(); $obj->delete('wrong'); } public function testSetEx1() { $this->expectException(ConfigException::class); $obj = new Config(); $obj->set('delay', 'some string'); } public function testSetEx2() { $this->expectException(ConfigException::class); $obj = new Config(); $obj->set('wrong', 'some string'); } public function testGet() { $obj = new Config(); $test1 = $obj->get('legacy'); $this->assertEquals($test1, false); $test2 = $obj->get('port'); $this->assertEquals($test2, 8728); $obj->set('port', 10000); $test3 = $obj->get('port'); $this->assertEquals($test3, 10000); $obj->delete('port'); $obj->set('ssl', true); $test3 = $obj->get('port'); $this->assertEquals($test3, 8729); } public function testGetEx() { $this->expectException(ConfigException::class); $obj = new Config(); $obj->get('wrong'); } }