Exemple #1
0
 public function testDefaultCsrfFieldNameCanBeSet()
 {
     Form::setDefaultCsrfFieldName('foobar');
     $form = new Form('author', new Author(), $this->validator);
     $form->enableCsrfProtection();
     $this->assertEquals('foobar', $form->getCsrfFieldName());
 }
 public function testIsCsrfTokenValidFails()
 {
     $provider = $this->createMockCsrfProvider();
     $provider->expects($this->once())->method('isCsrfTokenValid')->with($this->equalTo('Symfony\\Component\\Form\\Form'), $this->equalTo('ABCDEF'))->will($this->returnValue(false));
     $form = new Form('author', array('csrf_provider' => $provider, 'validator' => $this->validator));
     $field = $form->getCsrfFieldName();
     $form->submit(array($field => 'ABCDEF'));
     $this->assertFalse($form->isCsrfTokenValid());
 }