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()); }
/** * Test collect config, format var, order config */ public function testCollect() { $config = new Config(); $config->set('foo', 'bar'); $config->set('bar', 'foo'); $configDataCollector = new ConfigDataCollector($config); $dataFormatter = new DataFormatter(); $this->assertEquals(array('bar' => $dataFormatter->formatVar('foo'), 'foo' => $dataFormatter->formatVar('bar')), $configDataCollector->collect()); }