{ return $this->foo; } } // @Before $paramHolder = new Sonata_ParameterHolder(); $paramHolder->add($params = array('foo' => 42, 'bar' => 4711, 'baz' => new Foo())); // @After unset($paramHolder); unset($params); // @Test: ->add() $t->is($paramHolder->getAll(), $params, 'All parameters were added correctly'); $paramHolder->add(null); $t->isnt($paramHolder->getAll(), null, 'Nothing is added if NULL was given'); $paramHolder->add(array()); $t->isntSame($paramHolder->getAll(), array(), 'Nothing is added if an empty array was given'); $paramHolder->add('this fails'); $t->isnt($paramHolder->getAll(), 'this fails', 'Nothing is added if parameter isn\'t an array'); // @Test: ->get() $foo = $paramHolder->get('foo'); $t->is($foo, 42, 'The value is retrieved correctly'); $rex = $paramHolder->get('rex'); $t->is($rex, null, 'NULL is returned if the parameter could not be found'); $rex = $paramHolder->get('rex', 'fido'); $t->is($rex, 'fido', 'If a default value is given for a non-existing parameter, the default value is returned'); // @Test: ->getNames() $t->same($paramHolder->getNames(), array('foo', 'bar', 'baz'), 'All parameter names are retrieved correctly'); // @Test: ->has() $t->is($paramHolder->has('foo'), true, 'TRUE is returned if the parameter exists'); $t->is($paramHolder->has('rex'), false, 'FALSE is returned if the parameter does not exist'); // @Test: ->remove()