diff options
author | Igor Wiedler <igor@wiedler.ch> | 2011-01-10 00:18:37 +0100 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2011-01-10 00:18:37 +0100 |
commit | 01fe91c5c4e897801f5c179cd4060e686762f105 (patch) | |
tree | 178535f1cecfa2fd5748b21f9d59d1d471d1bd35 /tests/regex/ipv4_test.php | |
parent | 0a945100fd285658f1c3c936d413939eb11a6e16 (diff) | |
download | forums-01fe91c5c4e897801f5c179cd4060e686762f105.tar forums-01fe91c5c4e897801f5c179cd4060e686762f105.tar.gz forums-01fe91c5c4e897801f5c179cd4060e686762f105.tar.bz2 forums-01fe91c5c4e897801f5c179cd4060e686762f105.tar.xz forums-01fe91c5c4e897801f5c179cd4060e686762f105.zip |
[ticket/9987] Rename test files to include a _test suffix
PHPBB3-9987
Diffstat (limited to 'tests/regex/ipv4_test.php')
-rw-r--r-- | tests/regex/ipv4_test.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php new file mode 100644 index 0000000000..735a2c4384 --- /dev/null +++ b/tests/regex/ipv4_test.php @@ -0,0 +1,71 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +require_once __DIR__ . '/../../phpBB/includes/functions.php'; + +class phpbb_regex_ipv4_test extends phpbb_test_case +{ + protected $regex; + + public function setUp() + { + $this->regex = get_preg_expression('ipv4'); + } + + public function positive_match_data() + { + return array( + array('0.0.0.0'), + array('127.0.0.1'), + array('192.168.0.1'), + array('255.255.255.255'), + ); + } + + public function negative_match_data() + { + return array( + // IPv6 addresses + array('2001:0db8:85a3:0000:0000:8a2e:0370:1337'), + array('2001:db8:85a3:c:d:8a2e:370:1337'), + array('2001:db8:85a3::8a2e:370:1337'), + array('2001:db8:0:1::192.168.0.2'), + array('0:0:0:0:0:0:0:1'), + array('0:0::0:0:1'), + array('::1'), + + // Out of scope + array('255.255.255.256'), + + // Other tests + array('a.b.c.d'), + array('11.22.33.'), + array('11.22.33'), + array('11.22'), + array('11'), + ); + } + + /** + * @dataProvider positive_match_data + */ + public function test_positive_match($address) + { + $this->assertEquals(1, preg_match($this->regex, $address)); + } + + /** + * @dataProvider negative_match_data + */ + public function test_negative_match($address) + { + $this->assertEquals(0, preg_match($this->regex, $address)); + } +} + |