|
20 | 20 |
|
21 | 21 | class FixUrlProtocolListenerTest extends TestCase |
22 | 22 | { |
23 | | - public function testFixHttpUrl() |
| 23 | + public function provideUrlToFix() |
24 | 24 | { |
25 | | - $data = 'www.symfony.com'; |
26 | | - $form = new Form(new FormConfigBuilder('name', null, new EventDispatcher())); |
27 | | - $event = new FormEvent($form, $data); |
28 | | - |
29 | | - $filter = new FixUrlProtocolListener('http'); |
30 | | - $filter->onSubmit($event); |
31 | | - |
32 | | - $this->assertEquals('http://www.symfony.com', $event->getData()); |
| 25 | + return [ |
| 26 | + ['www.symfony.com'], |
| 27 | + ['twitter.com/@symfony'], |
| 28 | + ['symfony.com?foo@bar'], |
| 29 | + ['symfony.com#foo@bar'], |
| 30 | + ['localhost'], |
| 31 | + ]; |
33 | 32 | } |
34 | 33 |
|
35 | | - public function testSkipKnownUrl() |
| 34 | + /** |
| 35 | + * @dataProvider provideUrlToFix |
| 36 | + */ |
| 37 | + public function testFixUrl($data) |
36 | 38 | { |
37 | | - $data = 'http://www.symfony.com'; |
38 | 39 | $form = new Form(new FormConfigBuilder('name', null, new EventDispatcher())); |
39 | 40 | $event = new FormEvent($form, $data); |
40 | 41 |
|
41 | 42 | $filter = new FixUrlProtocolListener('http'); |
42 | 43 | $filter->onSubmit($event); |
43 | 44 |
|
44 | | - $this->assertEquals('http://www.symfony.com', $event->getData()); |
| 45 | + $this->assertEquals('http://'.$data, $event->getData()); |
45 | 46 | } |
46 | 47 |
|
47 | | - public function provideUrlsWithSupportedProtocols() |
| 48 | + public function provideUrlToSkip() |
48 | 49 | { |
49 | 50 | return [ |
| 51 | + ['http://www.symfony.com'], |
50 | 52 | ['ftp://www.symfony.com'], |
| 53 | + ['https://twitter.com/@symfony'], |
51 | 54 | ['chrome-extension://foo'], |
52 | 55 | ['h323://foo'], |
53 | 56 | ['iris.beep://foo'], |
54 | 57 | ['foo+bar://foo'], |
| 58 | + |
55 | 59 | ]; |
56 | 60 | } |
57 | 61 |
|
58 | 62 | /** |
59 | | - * @dataProvider provideUrlsWithSupportedProtocols |
| 63 | + * @dataProvider provideUrlToSkip |
60 | 64 | */ |
61 | | - public function testSkipOtherProtocol($url) |
| 65 | + public function testSkipUrl($url) |
62 | 66 | { |
63 | 67 | $form = new Form(new FormConfigBuilder('name', null, new EventDispatcher())); |
64 | 68 | $event = new FormEvent($form, $url); |
|
0 commit comments