Exemplo n.º 1
0
 public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes()
 {
     $element = new CsrfElement('foo');
     $inputSpec = $element->getInputSpecification();
     $this->assertArrayHasKey('validators', $inputSpec);
     $this->assertInternalType('array', $inputSpec['validators']);
     $expectedClasses = array('Zend\\Validator\\Csrf');
     foreach ($inputSpec['validators'] as $validator) {
         $class = get_class($validator);
         $this->assertTrue(in_array($class, $expectedClasses), $class);
         switch ($class) {
             case 'Zend\\Validator\\Csrf':
                 $this->assertEquals('foo', $validator->getName());
                 break;
             default:
                 break;
         }
     }
 }
Exemplo n.º 2
0
 public function testRendersCsrfAsExpected()
 {
     $element = new Element\Csrf('foo');
     $inputSpec = $element->getInputSpecification();
     $hash = '';
     foreach ($inputSpec['validators'] as $validator) {
         $class = get_class($validator);
         switch ($class) {
             case 'Zend\\Validator\\Csrf':
                 $hash = $validator->getHash();
                 break;
             default:
                 break;
         }
     }
     $markup = $this->helper->render($element);
     $this->assertRegexp('#<input[^>]*(type="hidden")#', $markup);
     $this->assertRegexp('#<input[^>]*(value="' . $hash . '")#', $markup);
 }