Ejemplo n.º 1
0
$testdelete->set('bla', 'woeiwoei');
assert('$testdelete->is_set("bla")');
$testdelete->delete('bla');
assert('!$testdelete->is_set("bla")');
/* Test underscores and dashes juggling */
$c = new AnewtContainer();
$c->set('foo_bar', 'baz');
assert('$c->get("foo-bar") === "baz"');
assert('$c->get("foo_bar") === "baz"');
$c->set('foo-bar', 'baz2');
assert('$c->get("foo-bar") === "baz2"');
assert('$c->get("foo_bar") === "baz2"');
$c->add('some-list', 'value');
$c->add('some_list', 'value');
assert('count($c->get("some-list")) === 2');
/* Test getdefault() and setdefault() */
$c = new AnewtContainer();
assert('$c->getdefault("foo", "defaultvalue") === "defaultvalue"');
$c->set('foo', 'anothervalue');
assert('$c->getdefault("foo", "defaultvalue") === "anothervalue"');
assert('$c->is_set("bar") === false');
$c->setdefault('bar', 'somevalue');
assert('$c->get("bar") === "somevalue"');
$c->set('bar', 'anothervalue');
assert('$c->get("bar") === "anothervalue"');
$c->setdefault('bar', 'somevalue');
/* should do nothing */
assert('$c->get("bar") === "anothervalue"');
$c->_set('foo', 'bar123');
assert('$c->_getdefault("bar") === "anothervalue"');
assert('$c->_getdefault("this-one-is-not-set", "the-answer") === "the-answer"');