New testcases for isValidUrl based on phps source code test cases
authorErnesto Baschny <ernst@cron-it.de>
Wed, 24 Feb 2010 19:19:22 +0000 (19:19 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Wed, 24 Feb 2010 19:19:22 +0000 (19:19 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7025 709f56b5-9817-0410-a4d7-c38de5d9e867

tests/t3lib/t3lib_div_testcase.php

index 450f760..c717b1a 100644 (file)
@@ -236,6 +236,63 @@ class t3lib_div_testcase extends tx_phpunit_testcase {
        }
 
        /**
+        * Data provider for valid URLs, like PHP's source code test cases
+        */
+       public function validUrlDataProvider() {
+               return array(
+                       array('http://example.com/index.html'),
+                       array('http://www.example.com/index.php'),
+                       array('http://www.example/img/test.png'),
+                       array('http://www.example/img/dir/'),
+                       array('http://www.example/img/dir'),
+                       array('file:///tmp/test.c'),
+                       array('ftp://ftp.example.com/tmp/'),
+                       array('mailto:foo@bar.com'),
+                       array('news:news.php.net'),
+                       array('file://foo/bar'),
+                       array('http://qwe'),
+               );
+       }
+
+       /**
+        * Data provider for invalid URLs, like PHP's source code test cases
+        */
+       public function invalidUrlDataProvider() {
+               return array(
+                       array('http//www.example/wrong/url/'),
+                       array('http:/www.example'),
+                       array('/tmp/test.c'),
+                       array('/'),
+                       array('http://'),
+                       array('http:/'),
+                       array('http:'),
+                       array('http'),
+                       array(''),
+                       array('-1'),
+                       array('array()'),
+                       array('qwe'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider validUrlDataProvider
+        * @see t3lib_div::isValidUrl()
+        */
+       public function checkisValidURL($url) {
+               $this->assertTrue(t3lib_div::isValidUrl($url));
+       }
+
+       /**
+        * @test
+        * @dataProvider invalidUrlDataProvider
+        * @see t3lib_div::isValidUrl()
+        */
+       public function checkisInValidURL($url) {
+               $this->assertFalse(t3lib_div::isValidUrl($url));
+       }
+
+       /**
         * @test
         * @see t3lib_div::isValidUrl()
         */