コード例 #1
0
ファイル: ConfigTest.php プロジェクト: itkg/core
 public function testGetSetValue()
 {
     // Explicit isset
     $this->assertFalse($this->config->has('nonexistent'));
     $this->assertTrue($this->config->has('bar'));
     // ArrayAccess isset
     $this->assertFalse(isset($this->config['you']));
     $this->assertTrue(isset($this->config['foo']));
     // Explicit getter
     $this->assertEquals($this->config->get('bar'), 'foo');
     // ArrayAccess getter
     $this->assertEquals($this->config->get('bar'), $this->config['bar']);
     // ArrayAccess setter
     $this->config['new'] = 'value';
     $this->assertEquals($this->config->get('new'), 'value', 'ArrayAccess set does not set value correctly');
     // Multi level ArrayAccess setter
     $this->config['ONE']['TWO'] = 'three';
     $this->assertEquals('three', $this->config['ONE']['TWO']);
     // Explicit setter
     $this->config->set('anotherOne', 'dummy');
     $this->assertEquals($this->config->get('anotherOne'), 'dummy', 'config::set() set does not set value correctly');
     // ArrayAccess on non existing key returns null
     $this->assertNull($this->config['WTF']);
     // Get all values
     $this->assertInternalType('array', $this->config->all());
 }