20
20
21
21
class FixUrlProtocolListenerTest extends TestCase
22
22
{
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
+
23
37
public function provideUrlToFix ()
24
38
{
25
39
return [
26
40
['www.symfony.com ' ],
41
+ ['symfony.com/doc ' ],
27
42
['twitter.com/@symfony ' ],
28
43
['symfony.com?foo@bar ' ],
29
44
['symfony.com#foo@bar ' ],
@@ -32,17 +47,17 @@ public function provideUrlToFix()
32
47
}
33
48
34
49
/**
35
- * @dataProvider provideUrlToFix
50
+ * @dataProvider provideUrlToSkip
36
51
*/
37
- public function testFixUrl ( $ data )
52
+ public function testSkipUrl ( $ url )
38
53
{
39
54
$ form = new Form (new FormConfigBuilder ('name ' , null , new EventDispatcher ()));
40
- $ event = new FormEvent ($ form , $ data );
55
+ $ event = new FormEvent ($ form , $ url );
41
56
42
57
$ filter = new FixUrlProtocolListener ('http ' );
43
58
$ filter ->onSubmit ($ event );
44
59
45
- $ this ->assertEquals ( ' http:// ' . $ data , $ event ->getData ());
60
+ $ this ->assertSame ( $ url , $ event ->getData ());
46
61
}
47
62
48
63
public function provideUrlToSkip ()
@@ -56,20 +71,9 @@ public function provideUrlToSkip()
56
71
['iris.beep://foo ' ],
57
72
['foo+bar://foo ' ],
58
73
74
+ ['//relative/url ' ],
75
+ ['/relative/url ' ],
76
+ ['./relative/url ' ],
59
77
];
60
78
}
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
- }
75
79
}
0 commit comments