summaryrefslogtreecommitdiff
path: root/tests/Framework/Utils.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-08-27 12:23:30 +0200
committerAleksander Machniak <alec@alec.pl>2012-08-27 12:23:30 +0200
commita65ce5d3b07deb578cc4c4aba5695bcea8c07a87 (patch)
treea3b441a115e7081a326da104444fea707034522f /tests/Framework/Utils.php
parent6075f084ecbff71490fc5594f2d9470d87938317 (diff)
Rename ip_check to check_ip, add IP checking tests
Diffstat (limited to 'tests/Framework/Utils.php')
-rw-r--r--tests/Framework/Utils.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php
index b6cc5d577..503b69a4a 100644
--- a/tests/Framework/Utils.php
+++ b/tests/Framework/Utils.php
@@ -83,6 +83,53 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
}
/**
+ * Valid IP addresses for test_valid_ip()
+ */
+ function data_valid_ip()
+ {
+ return array(
+ array('0.0.0.0'),
+ array('123.123.123.123'),
+ array('::'),
+ array('::1'),
+ array('::1.2.3.4'),
+ array('2001:2d12:c4fe:5afe::1'),
+ );
+ }
+
+ /**
+ * Valid IP addresses for test_invalid_ip()
+ */
+ function data_invalid_ip()
+ {
+ return array(
+ array(''),
+ array(0),
+ array('123.123.123.1234'),
+ array('1.1.1.1.1'),
+ array('::1.2.3.260'),
+ array('::1.0'),
+ array('2001::c4fe:5afe::1'),
+ );
+ }
+
+ /**
+ * @dataProvider data_valid_ip
+ */
+ function test_valid_ip($ip)
+ {
+ $this->assertTrue(rcube_utils::check_ip($ip));
+ }
+
+ /**
+ * @dataProvider data_invalid_ip
+ */
+ function test_invalid_ip($ip)
+ {
+ $this->assertFalse(rcube_utils::check_ip($ip));
+ }
+
+ /**
* rcube_utils::mod_css_styles()
*/
function test_mod_css_styles()