public function testFromArray() { $firstArray = ['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']; $config = new Configuration(); $config->fromArray($firstArray); $reflection = new ReflectionProperty($config, 'container'); $reflection->setAccessible(true); $this->assertSame($firstArray, $reflection->getValue($config)); $secondArray = ['bar' => 'bat', 'con' => 'com']; $config->fromArray($secondArray); $expected = array_merge($firstArray, $secondArray); $this->assertSame($expected, $reflection->getValue($config)); }
public function testIsEmpty() { $container = new Configuration(); $this->assertTrue($container->isEmpty()); $container->foo = 'bar'; $this->assertFalse($container->isEmpty()); unset($container->foo); $this->assertTrue($container->isEmpty()); $container['foo'] = 'bar'; $this->assertFalse($container->isEmpty()); unset($container['foo']); $this->assertTrue($container->isEmpty()); }
public function testGetReturnsDefault() { $config = new Configuration(); $this->assertSame('bar', $config->get('foo', 'bar')); }
public function testMergeMergingTwoNestedArrays() { $arrayFirst = ['foo' => ['bar' => ['baz' => 100, 300]]]; $arraySecond = ['foo' => ['bar' => ['baz' => 200, 400]]]; $expected = ['foo' => ['bar' => ['baz' => 200, 300, 400]]]; $config = new Configuration(); $config->fromArray($arrayFirst); // $config->merge($arraySecond); $this->assertSame($expected, $config->toArray()); }