reset() public static method

重置配置参数
public static reset ( $range = '' )
Example #1
0
 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();
 }
Example #2
0
 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();
 }
Example #3
0
 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);
 }