$t->is($ph->has('bar'), false, '->has() returns false if the key does not exist'); $t->is($ph->has('myfoo'), false, '->has() returns false if the key exists but in another namespace'); $t->is($ph->has('myfoo', 'symfony/mynamespace'), true, '->has() returns true if the key exists in the namespace given as its second argument'); $ph = new sfParameterHolder(); $ph->add(array('foo' => array('bar' => array('baz' => 'foo bar'), 'bars' => array('foo', 'bar')))); $t->is($ph->has('foo[bar][baz]'), true, '->has() can takes a multi-array key'); $t->is($ph->get('foo[bars][1]'), true, '->has() can takes a multi-array key'); $t->is($ph->get('foo[bars][2]'), false, '->has() returns null is the key does not exist'); $t->is($ph->has('foo[bars][]'), true, '->has() returns true if an array exists'); $t->is($ph->get('foo[bars][]'), $ph->has('foo[bars]'), '->has() returns true for an array even if you omit the []'); // ->hasNamespace() $t->diag('->hasNamespace()'); $ph = new sfParameterHolder(); $ph->set('foo', 'bar'); $ph->set('myfoo', 'bar', 'symfony/mynamespace'); $t->is($ph->hasNamespace($ph->getDefaultNamespace()), true, '->hasNamespace() returns true for the default namespace'); $t->is($ph->hasNamespace('symfony/mynamespace'), true, '->hasNamespace() returns true if the namespace exists'); $t->is($ph->hasNamespace('symfony/nonexistant'), false, '->hasNamespace() returns false if the namespace does not exist'); // ->remove() $t->diag('->remove()'); $ph = new sfParameterHolder(); $ph->set('foo', 'bar'); $ph->set('myfoo', 'bar'); $ph->set('myfoo', 'bar', 'symfony/mynamespace'); $ph->remove('foo'); $t->is($ph->has('foo'), false, '->remove() removes the key from parameters'); $ph->remove('myfoo'); $t->is($ph->has('myfoo'), false, '->remove() removes the key from parameters'); $t->is($ph->has('myfoo', 'symfony/mynamespace'), true, '->remove() removes the key from parameters for a given namespace'); $ph->remove('myfoo', 'symfony/mynamespace'); $t->is($ph->has('myfoo', 'symfony/mynamespace'), false, '->remove() takes a namespace as its second argument');