diff options
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php deleted file mode 100644 index 0bcfe74e..00000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
1 | <?php | ||
2 | |||
3 | /* | ||
4 | * This file is part of the Symfony package. | ||
5 | * | ||
6 | * (c) Fabien Potencier <fabien@symfony.com> | ||
7 | * | ||
8 | * For the full copyright and license information, please view the LICENSE | ||
9 | * file that was distributed with this source code. | ||
10 | */ | ||
11 | |||
12 | namespace Symfony\Component\Form\Tests\Extension\Csrf\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormBuilder; | ||
15 | use Symfony\Component\Form\FormEvent; | ||
16 | use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener; | ||
17 | |||
18 | class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase | ||
19 | { | ||
20 | protected $dispatcher; | ||
21 | protected $factory; | ||
22 | protected $csrfProvider; | ||
23 | |||
24 | protected function setUp() | ||
25 | { | ||
26 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
27 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
28 | } | ||
29 | |||
30 | $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); | ||
31 | $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); | ||
32 | $this->csrfProvider = $this->getMock('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'); | ||
33 | $this->form = $this->getBuilder('post') | ||
34 | ->setDataMapper($this->getDataMapper()) | ||
35 | ->getForm(); | ||
36 | } | ||
37 | |||
38 | protected function tearDown() | ||
39 | { | ||
40 | $this->dispatcher = null; | ||
41 | $this->factory = null; | ||
42 | $this->csrfProvider = null; | ||
43 | $this->form = null; | ||
44 | } | ||
45 | |||
46 | protected function getBuilder($name = 'name') | ||
47 | { | ||
48 | return new FormBuilder($name, null, $this->dispatcher, $this->factory, array('compound' => true)); | ||
49 | } | ||
50 | |||
51 | protected function getForm($name = 'name') | ||
52 | { | ||
53 | return $this->getBuilder($name)->getForm(); | ||
54 | } | ||
55 | |||
56 | protected function getDataMapper() | ||
57 | { | ||
58 | return $this->getMock('Symfony\Component\Form\DataMapperInterface'); | ||
59 | } | ||
60 | |||
61 | protected function getMockForm() | ||
62 | { | ||
63 | return $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
64 | } | ||
65 | |||
66 | // https://github.com/symfony/symfony/pull/5838 | ||
67 | public function testStringFormData() | ||
68 | { | ||
69 | $data = "XP4HUzmHPi"; | ||
70 | $event = new FormEvent($this->form, $data); | ||
71 | |||
72 | $validation = new CsrfValidationListener('csrf', $this->csrfProvider, 'unknown', 'Invalid.'); | ||
73 | $validation->preSubmit($event); | ||
74 | |||
75 | // Validate accordingly | ||
76 | $this->assertSame($data, $event->getData()); | ||
77 | } | ||
78 | } | ||