diff options
Diffstat (limited to 'vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php')
-rw-r--r-- | vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php new file mode 100644 index 00000000..2b84e4fd --- /dev/null +++ b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php | |||
@@ -0,0 +1,61 @@ | |||
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\Core\EventListener; | ||
13 | |||
14 | use Symfony\Component\Form\FormEvent; | ||
15 | use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener; | ||
16 | |||
17 | class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase | ||
18 | { | ||
19 | protected function setUp() | ||
20 | { | ||
21 | if (!class_exists('Symfony\Component\EventDispatcher\EventDispatcher')) { | ||
22 | $this->markTestSkipped('The "EventDispatcher" component is not available'); | ||
23 | } | ||
24 | } | ||
25 | |||
26 | public function testFixHttpUrl() | ||
27 | { | ||
28 | $data = "www.symfony.com"; | ||
29 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
30 | $event = new FormEvent($form, $data); | ||
31 | |||
32 | $filter = new FixUrlProtocolListener('http'); | ||
33 | $filter->onSubmit($event); | ||
34 | |||
35 | $this->assertEquals('http://www.symfony.com', $event->getData()); | ||
36 | } | ||
37 | |||
38 | public function testSkipKnownUrl() | ||
39 | { | ||
40 | $data = "http://www.symfony.com"; | ||
41 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
42 | $event = new FormEvent($form, $data); | ||
43 | |||
44 | $filter = new FixUrlProtocolListener('http'); | ||
45 | $filter->onSubmit($event); | ||
46 | |||
47 | $this->assertEquals('http://www.symfony.com', $event->getData()); | ||
48 | } | ||
49 | |||
50 | public function testSkipOtherProtocol() | ||
51 | { | ||
52 | $data = "ftp://www.symfony.com"; | ||
53 | $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); | ||
54 | $event = new FormEvent($form, $data); | ||
55 | |||
56 | $filter = new FixUrlProtocolListener('http'); | ||
57 | $filter->onSubmit($event); | ||
58 | |||
59 | $this->assertEquals('ftp://www.symfony.com', $event->getData()); | ||
60 | } | ||
61 | } | ||