예제 #1
0
<?php

require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
$t = new lime_test(27);
$t->comment('nbConfigTest - Test get all');
$configuration = new nbConfiguration();
$t->is($configuration->getAll(), array(), '->getAll() returns all configuration keys');
$configuration->set('foo', 'fooValue');
$t->is($configuration->getAll(), array('foo' => 'fooValue'), '->getAll() returns all configuration keys');
$configuration->set('bar', 'barValue');
$t->comment('nbConfigTest - Test remove');
$configuration = new nbConfiguration();
$configuration->set('bar', 'barValue');
$configuration->remove('bar');
$t->is($configuration->getAll(), array(), '->remove() removes a sigle configuration key');
$t->comment('nbConfigTest - Test reset');
$configuration = new nbConfiguration();
$configuration->set('foo', 'fooValue');
$configuration->set('bar', 'barValue');
$t->is(count($configuration->getAll()), 2, '->reset() remove all keys');
$configuration->reset();
$t->is($configuration->getAll(), array(), '->reset() remove all keys');
$t->comment('nbConfigTest - Test has');
$configuration = new nbConfiguration();
$t->is($configuration->has('key'), false, '$configuration->has() returns false if key is not present');
$configuration->set('key', 'value');
$t->is($configuration->has('key'), true, '$configuration->has() returns true if key is present');
$key2 = array('foo' => 'fooValue');
$configuration->set('key2', $key2);
$t->is($configuration->has('key2_foo'), true, '$configuration->has() returns true if "key path" is present');
$t->comment('nbConfigTest - Test get');