public function testConfig() { App::run(); $this->assertTrue(Config::has('url_route_on')); $this->assertEquals(1, Config::get('url_route_on')); Config::set('url_route_on', false); $this->assertEquals(0, Config::get('url_route_on')); Config::range('test'); $this->assertFalse(Config::has('url_route_on')); Config::reset(); }
public function testConfig() { App::run(Config::get()); Config::parse('isTrue=1', 'test'); Config::range('test'); $this->assertTrue(Config::has('isTrue')); $this->assertEquals(1, Config::get('isTrue')); Config::set('isTrue', false); $this->assertEquals(0, Config::get('isTrue')); Config::reset(); }
public function testReset() { $range = '_test_'; $reflectedClass = new ReflectionClass('\\think\\Config'); $reflectedPropertyConfig = $reflectedClass->getProperty('config'); $reflectedPropertyConfig->setAccessible(true); $reflectedPropertyConfig->setValue([$range => ['abcd' => 'efg']]); // clear all configurations Config::reset(true); $config = $reflectedPropertyConfig->getValue(); $this->assertEquals([], $config); // clear the configuration in range of parameter. $reflectedPropertyConfig->setValue([$range => ['abcd' => 'efg', 'hijk' => 'lmn'], 'a' => 'b']); Config::reset($range); $config = $reflectedPropertyConfig->getValue(); $this->assertEquals([$range => [], 'a' => 'b'], $config); }