config : allow to have the defaults params in ->get() in case of array without defined key
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2648 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -151,4 +151,107 @@ class test_config extends PHPUnit_Framework_TestCase
|
||||
"tableprefix"=>false));
|
||||
$this->assertSame (true, $res);
|
||||
}
|
||||
|
||||
public function testGet6 ()
|
||||
{
|
||||
$c = new config ();
|
||||
$c->confFile = "/tmp/testconf.php";
|
||||
chmod ("/tmp/testconf.php", 0666);
|
||||
$c->default = array (
|
||||
"database"=>array (
|
||||
"dsn"=>null,
|
||||
"user"=>null,
|
||||
"password"=>null,
|
||||
"tableprefix"=>""),
|
||||
"servers"=>array (
|
||||
"not configured"=>array (
|
||||
"type"=>"bind",
|
||||
"username"=>"",
|
||||
),
|
||||
)
|
||||
);
|
||||
$res = $c->get ("servers");
|
||||
$this->assertSame ($res, array ("not configured"=>array (
|
||||
"type"=>"bind",
|
||||
"username"=>"",
|
||||
)));
|
||||
}
|
||||
|
||||
public function testSet7 ()
|
||||
{
|
||||
$c = new config ();
|
||||
$c->confFile = "/tmp/testconf.php";
|
||||
chmod ("/tmp/testconf.php", 0666);
|
||||
$c->default = array (
|
||||
"database"=>array (
|
||||
"dsn"=>null,
|
||||
"user"=>null,
|
||||
"password"=>null,
|
||||
"tableprefix"=>""),
|
||||
"servers"=>array (
|
||||
"not configured"=>array (
|
||||
"type"=>"bind",
|
||||
"username"=>"",
|
||||
),
|
||||
)
|
||||
);
|
||||
$res = $c->set ("servers", array (
|
||||
"127.0.0.1"=>array (
|
||||
"type"=>"BIND",
|
||||
"username"=>"toto",
|
||||
)));
|
||||
}
|
||||
public function testGet7 ()
|
||||
{
|
||||
$c = new config ();
|
||||
$c->confFile = "/tmp/testconf.php";
|
||||
chmod ("/tmp/testconf.php", 0666);
|
||||
$c->default = array (
|
||||
"database"=>array (
|
||||
"dsn"=>null,
|
||||
"user"=>null,
|
||||
"password"=>null,
|
||||
"tableprefix"=>""),
|
||||
"servers"=>array (
|
||||
"not configured"=>array (
|
||||
"type"=>"bind",
|
||||
"username"=>"",
|
||||
),
|
||||
)
|
||||
);
|
||||
$res = $c->get ("servers");
|
||||
$this->assertSame ($res, array (
|
||||
"127.0.0.1"=>array (
|
||||
"type"=>"BIND",
|
||||
"username"=>"toto",
|
||||
)));
|
||||
}
|
||||
|
||||
public function testGet8 ()
|
||||
{
|
||||
$c = new config ();
|
||||
$c->confFile = "/tmp/testconf.php";
|
||||
chmod ("/tmp/testconf.php", 0666);
|
||||
$c->default = array (
|
||||
"database"=>array (
|
||||
"dsn"=>null,
|
||||
"user"=>null,
|
||||
"password"=>null,
|
||||
"tableprefix"=>""),
|
||||
"servers"=>array (
|
||||
"not configured"=>array (
|
||||
"type"=>"bind",
|
||||
"username"=>"",
|
||||
"password"=>"",
|
||||
),
|
||||
)
|
||||
);
|
||||
$res = $c->get ("servers");
|
||||
$this->assertSame ($res, array (
|
||||
"127.0.0.1"=>array (
|
||||
"type"=>"BIND",
|
||||
"username"=>"toto",
|
||||
"password"=>"",
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user