Fixed bug #14968: Add unit tests for t3lib_div::validIP (Thanks to Nikolas Hagelstein...
authorChristian Kuhn <lolli@schwarzbu.ch>
Wed, 7 Jul 2010 18:12:24 +0000 (18:12 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 7 Jul 2010 18:12:24 +0000 (18:12 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8131 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/t3lib_divTest.php

index a33f86e..0c969c2 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-07-07  Christian Kuhn  <lolli@schwarzbu.ch>
+
+       * Fixed bug #14968: Add unit tests for t3lib_div::validIP (Thanks to Nikolas Hagelstein and Felix Kopp)
+
 2010-07-07  Susanne Moog  <typo3@susanne-moog.de>
 
        * Follow-up to #14845: No preview images with referenced files anymore (thanks to Stefan Galinski)
index 602e88d..2ecc2a6 100644 (file)
@@ -57,6 +57,64 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
 
        ///////////////////////////////
+       // Tests concerning validIP
+       ///////////////////////////////
+
+       /**
+        * Data provider for checkValidIpReturnsTrueForValidIp
+        *
+        * @return array Data sets
+        */
+       public static function validIpDataProvider() {
+               return array(
+                       '0.0.0.0' => array('0.0.0.0'),
+                       'private IPv4 class C' => array('192.168.0.1'),
+                       'private IPv4 class A' => array('10.0.13.1'),
+                       'private IPv6' => array('fe80::daa2:5eff:fe8b:7dfb'),
+               );
+       }
+
+       /**
+        * Checks if t3lib_div::validIP() returns true for valid IPs
+        *
+        * @test
+        * @see t3lib_div::validIP()
+        * @dataProvider validIpDataProvider
+        */
+       public function checkValidIpReturnsTrueForValidIp($ip) {
+               $this->assertTrue(t3lib_div::validIP($ip));
+       }
+
+       /**
+        * Data provider for checkValidIpReturnsFalseForInvalidIp
+        *
+        * @return array Data sets
+        */
+       public static function invalidIpDataProvider() {
+               return array(
+                       'null' => array(null),
+                       'zero' => array(0),
+                       'string' => array('test'),
+                       'string empty' => array(''),
+                       'string null' => array('null'),
+                       'out of bounds IPv4' => array('300.300.300.300'),
+                       'wrong dotted decimal notation with only two dots' => array('127.0.1'),
+               );
+       }
+
+       /**
+        * Checks if t3lib_div::validIP() returns false for invalid IPs
+        *
+        * @test
+        * @see t3lib_div::validIP()
+        * @dataProvider invalidIpDataProvider
+        */
+       public function checkValidIpReturnsFalseForInvalidIp($ip) {
+               $this->assertFalse(t3lib_div::validIP($ip));
+       }
+
+
+       ///////////////////////////////
        // Tests concerning splitCalc
        ///////////////////////////////