|
@@ -51,14 +51,28 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
|
|
public function getValidUrls()
|
|
|
{
|
|
|
return array(
|
|
|
+ array('http://a.pl'),
|
|
|
array('http://www.google.com'),
|
|
|
+ array('http://www.google.museum'),
|
|
|
+ array('http://google.বাংলা/'),
|
|
|
+ array('http://google.ąęź/'),
|
|
|
array('https://google.com/'),
|
|
|
array('https://google.com:80/'),
|
|
|
+ array('http://א-ת.com/'),
|
|
|
+ array('http://żółw.żółw/'),
|
|
|
+ array('http://àlàl.com:80/'),
|
|
|
+ array('http://www.example.coop/'),
|
|
|
+ array('http://www.test-example.com/'),
|
|
|
array('http://www.symfony.com/'),
|
|
|
+ array('http://symfony.fake/blog/'),
|
|
|
+ array('http://symfony.com/search?type=&q=url+validator'),
|
|
|
+ array('http://www.symfony.com/doc/current/book/validation.html#supported-constraints'),
|
|
|
+ array('http://very.long.domain.name.com/'),
|
|
|
array('http://127.0.0.1/'),
|
|
|
array('http://127.0.0.1:80/'),
|
|
|
array('http://[::1]/'),
|
|
|
array('http://[::1]:80/'),
|
|
|
+ array('http://[1:2:3::4:5:6:7]/'),
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -74,10 +88,40 @@ class UrlValidatorTest extends \PHPUnit_Framework_TestCase
|
|
|
{
|
|
|
return array(
|
|
|
array('google.com'),
|
|
|
+ array('://google.com'),
|
|
|
+ array('http ://google.com'),
|
|
|
array('http:/google.com'),
|
|
|
+ array('http://goog_le.com'),
|
|
|
array('http://google.com::aa'),
|
|
|
+ array('http://google.com:aa'),
|
|
|
array('http://google.foobar'),
|
|
|
array('ftp://google.fr'),
|
|
|
+ array('faked://google.fr'),
|
|
|
+ array('http://127.0.0.1:aa/'),
|
|
|
+ array('http://127.0.0.1:123456/'),
|
|
|
+ array('ftp://[::1]/'),
|
|
|
+ array('http://[::1'),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @dataProvider getValidCustomUrls
|
|
|
+ */
|
|
|
+ public function testCustomProtocolIsValid($url)
|
|
|
+ {
|
|
|
+ $constraint = new Url(array(
|
|
|
+ 'protocols' => array('ftp', 'file', 'git')
|
|
|
+ ));
|
|
|
+
|
|
|
+ $this->assertTrue($this->validator->isValid($url, $constraint));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function getValidCustomUrls()
|
|
|
+ {
|
|
|
+ return array(
|
|
|
+ array('ftp://google.com'),
|
|
|
+ array('file://127.0.0.1'),
|
|
|
+ array('git://[::1]/'),
|
|
|
);
|
|
|
}
|
|
|
|