Permalink
Browse files

Make Fieldset constructor consistent with parent Element class

  • Loading branch information...
1 parent bcc6ee9 commit 480c49fff13f4f8555608531976e3dcbdf39e537 @cgmartin committed Sep 8, 2012
Showing with 14 additions and 5 deletions.
  1. +4 −5 library/Zend/Form/Fieldset.php
  2. +10 −0 tests/ZendTest/Form/FieldsetTest.php
@@ -73,14 +73,13 @@ class Fieldset extends Element implements FieldsetInterface
protected $useAsBaseFieldset = false;
/**
- * Constructor
- *
- * @param null|string|int $name Optional name for the element
+ * @param null|int|string $name Optional name for the element
+ * @param array $options Optional options for the element
*/
- public function __construct($name = null)
+ public function __construct($name = null, $options = array())
{
$this->iterator = new PriorityQueue();
- parent::__construct($name);
+ parent::__construct($name, $options);
}
/**
@@ -104,6 +104,16 @@ public function testCanAddElementsToFieldset()
$this->assertEquals(1, count($this->fieldset));
}
+ public function testCanSetCustomOptionFromConstructor()
+ {
+ $fieldset = new Fieldset('foo', array(
+ 'custom' => 'option'
+ ));
+ $options = $fieldset->getOptions();
+ $this->assertArrayHasKey('custom', $options);
+ $this->assertEquals('option', $options['custom']);
+ }
+
public function testCanGrabElementByNameWhenNotProvidedWithAlias()
{
$element = new Element('foo');

0 comments on commit 480c49f

Please sign in to comment.