Exemplo n.º 1
0
 public function testImport()
 {
     $collection = new A_Collection(array('foo' => 'bar', 'baz' => array('foobar' => 'barfoo'), 'bar' => 'baz'));
     $return = $collection->import(array('bar' => 'foo', 'baz' => array('foo' => 'bar'), 'barfoo' => 'foo'));
     $this->assertEqual($collection->get('foo'), 'bar');
     $this->assertEqual($collection->get('baz')->get('foobar'), 'barfoo');
     $this->assertEqual($collection->get('baz')->get('foo'), 'bar');
     $this->assertEqual($collection->get('bar'), 'foo');
     $this->assertEqual($collection->get('barfoo'), 'foo');
     $this->assertEqual($collection->count(), 4);
     $this->assertEqual($collection->get('baz')->count(), 2);
     // make sure import() returns self
     $this->assertEqual($return, $collection);
 }
Exemplo n.º 2
0
<?php

include 'config.php';
$configdata = array('APP' => '/path/to/app/', 'BASE' => 'http://www.example.com');
$config = new A_Collection($configdata);
$config->import(simplexml_load_file("example.xml"), 'xml');
$config->import(parse_ini_file("example.ini", true), 'ini');
echo "\$config->xml->first_section->animal = {$config->xml->first_section->animal}<br/>";
echo "\$config->ini->first_section->animal = {$config->ini->first_section->animal}<br/>";
dump($config);