2020
2121class FixUrlProtocolListenerTest extends TestCase
2222{
23+ /**
24+ * @dataProvider provideUrlToFix
25+ */
26+ public function testFixUrl ($ data )
27+ {
28+ $ form = new Form (new FormConfigBuilder ('name ' , null , new EventDispatcher ()));
29+ $ event = new FormEvent ($ form , $ data );
30+
31+ $ filter = new FixUrlProtocolListener ('http ' );
32+ $ filter ->onSubmit ($ event );
33+
34+ $ this ->assertSame ('http:// ' .$ data , $ event ->getData ());
35+ }
36+
2337 public function provideUrlToFix ()
2438 {
2539 return [
2640 ['www.symfony.com ' ],
41+ ['symfony.com/doc ' ],
2742 ['twitter.com/@symfony ' ],
2843 ['symfony.com?foo@bar ' ],
2944 ['symfony.com#foo@bar ' ],
@@ -32,17 +47,17 @@ public function provideUrlToFix()
3247 }
3348
3449 /**
35- * @dataProvider provideUrlToFix
50+ * @dataProvider provideUrlToSkip
3651 */
37- public function testFixUrl ( $ data )
52+ public function testSkipUrl ( $ url )
3853 {
3954 $ form = new Form (new FormConfigBuilder ('name ' , null , new EventDispatcher ()));
40- $ event = new FormEvent ($ form , $ data );
55+ $ event = new FormEvent ($ form , $ url );
4156
4257 $ filter = new FixUrlProtocolListener ('http ' );
4358 $ filter ->onSubmit ($ event );
4459
45- $ this ->assertEquals ( ' http:// ' . $ data , $ event ->getData ());
60+ $ this ->assertSame ( $ url , $ event ->getData ());
4661 }
4762
4863 public function provideUrlToSkip ()
@@ -56,20 +71,9 @@ public function provideUrlToSkip()
5671 ['iris.beep://foo ' ],
5772 ['foo+bar://foo ' ],
587374+ ['//relative/url ' ],
75+ ['/relative/url ' ],
76+ ['./relative/url ' ],
5977 ];
6078 }
61-
62- /**
63- * @dataProvider provideUrlToSkip
64- */
65- public function testSkipUrl ($ url )
66- {
67- $ form = new Form (new FormConfigBuilder ('name ' , null , new EventDispatcher ()));
68- $ event = new FormEvent ($ form , $ url );
69-
70- $ filter = new FixUrlProtocolListener ('http ' );
71- $ filter ->onSubmit ($ event );
72-
73- $ this ->assertEquals ($ url , $ event ->getData ());
74- }
7579}
0 commit comments