/** * @dataProvider useHiddenAttributeDataProvider */ public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes($useHiddenElement) { $element = new RadioElement(); $options = array('1' => 'Option 1', '2' => 'Option 2', '3' => 'Option 3'); $element->setAttributes(array('options' => $options)); $element->setUseHiddenElement($useHiddenElement); $inputSpec = $element->getInputSpecification(); $this->assertArrayHasKey('validators', $inputSpec); $this->assertInternalType('array', $inputSpec['validators']); $expectedClasses = array('Zend\\Validator\\InArray'); foreach ($inputSpec['validators'] as $validator) { $class = get_class($validator); $this->assertTrue(in_array($class, $expectedClasses), $class); switch ($class) { case 'Zend\\Validator\\InArray': $values = array_values($options); if ($element->useHiddenElement()) { $values[] = $element->getUncheckedValue(); } $this->assertEquals($values, $validator->getHaystack()); break; default: break; } } }