Make Fieldset constructor consistent with parent Element class #2317

Merged
merged 1 commit into from Sep 13, 2012
@@ -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');