/** * Test flatten. * * @return void * * @covers Joomla\Registry\Registry::flatten * @since 1.3.0 */ public function testFlatten() { $a = new Registry(); $a->set('flower.sunflower', 'light'); $a->set('flower.sakura', 'samurai'); $flatted = $a->flatten(); $this->assertEquals($flatted['flower.sunflower'], 'light'); $flatted = $a->flatten('/'); $this->assertEquals($flatted['flower/sakura'], 'samurai'); }
/** * @testdox The Registry can be flattened to an array * * @covers Joomla\Registry\Registry::flatten * @covers Joomla\Registry\Registry::toFlatten */ public function testTheRegistryCanBeFlattenedToAnArray() { $a = new Registry(array('flower' => array('sunflower' => 'light', 'sakura' => 'samurai'))); $flattened = $a->flatten(); $this->assertEquals($flattened['flower.sunflower'], 'light', 'The Registry is flattened to an array.'); $flattened = $a->flatten('/'); $this->assertEquals($flattened['flower/sakura'], 'samurai', 'The Registry is flattened to an array with a custom path separator.'); }