From 01fe91c5c4e897801f5c179cd4060e686762f105 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 10 Jan 2011 00:18:37 +0100 Subject: [ticket/9987] Rename test files to include a _test suffix PHPBB3-9987 --- tests/regex/censor.php | 40 ------------- tests/regex/censor_test.php | 40 +++++++++++++ tests/regex/email.php | 118 ------------------------------------ tests/regex/email_test.php | 118 ++++++++++++++++++++++++++++++++++++ tests/regex/ipv4.php | 71 ---------------------- tests/regex/ipv4_test.php | 71 ++++++++++++++++++++++ tests/regex/ipv6.php | 142 -------------------------------------------- tests/regex/ipv6_test.php | 142 ++++++++++++++++++++++++++++++++++++++++++++ tests/regex/url.php | 33 ---------- tests/regex/url_test.php | 33 ++++++++++ 10 files changed, 404 insertions(+), 404 deletions(-) delete mode 100644 tests/regex/censor.php create mode 100644 tests/regex/censor_test.php delete mode 100644 tests/regex/email.php create mode 100644 tests/regex/email_test.php delete mode 100644 tests/regex/ipv4.php create mode 100644 tests/regex/ipv4_test.php delete mode 100644 tests/regex/ipv6.php create mode 100644 tests/regex/ipv6_test.php delete mode 100644 tests/regex/url.php create mode 100644 tests/regex/url_test.php (limited to 'tests/regex') diff --git a/tests/regex/censor.php b/tests/regex/censor.php deleted file mode 100644 index ae2d86e07e..0000000000 --- a/tests/regex/censor.php +++ /dev/null @@ -1,40 +0,0 @@ -assertRegExp($regex, $subject); - } -} \ No newline at end of file diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php new file mode 100644 index 0000000000..ae2d86e07e --- /dev/null +++ b/tests/regex/censor_test.php @@ -0,0 +1,40 @@ +assertRegExp($regex, $subject); + } +} \ No newline at end of file diff --git a/tests/regex/email.php b/tests/regex/email.php deleted file mode 100644 index 5d6e207cbb..0000000000 --- a/tests/regex/email.php +++ /dev/null @@ -1,118 +0,0 @@ -regex = '#^' . get_preg_expression('email') . '$#i'; - } - - public function positive_match_data() - { - return array( - array('nobody@phpbb.com'), - array('Nobody@sub.phpbb.com'), - array('alice.bob@foo.phpbb.com'), - array('alice-foo@bar.phpbb.com'), - array('alice_foo@bar.phpbb.com'), - array('alice+tag@foo.phpbb.com'), - array('alice&tag@foo.phpbb.com'), - - //array('"John Doe"@example.com'), - //array('Alice@[192.168.2.1]'), // IPv4 - //array('Bob@[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]'), // IPv6 - - // http://fightingforalostcause.net/misc/2006/compare-email-regex.php - array('l3tt3rsAndNumb3rs@domain.com'), - array('has-dash@domain.com'), - array('hasApostrophe.o\'leary@domain.org'), - array('uncommonTLD@domain.museum'), - array('uncommonTLD@domain.travel'), - array('uncommonTLD@domain.mobi'), - array('countryCodeTLD@domain.uk'), - array('countryCodeTLD@domain.rw'), - array('numbersInDomain@911.com'), - array('underscore_inLocal@domain.net'), - array('IPInsteadOfDomain@127.0.0.1'), - array('IPAndPort@127.0.0.1:25'), - array('subdomain@sub.domain.com'), - array('local@dash-inDomain.com'), - array('dot.inLocal@foo.com'), - array('a@singleLetterLocal.org'), - array('singleLetterDomain@x.org'), - array('&*=?^+{}\'~@validCharsInLocal.net'), - array('foor@bar.newTLD'), - ); - } - - public function negative_match_data() - { - return array( - array('foo.example.com'), // @ is missing - array('.foo.example.com'), // . as first character - array('Foo.@example.com'), // . is last in local part - array('foo..123@example.com'), // . doubled - array('a@b@c@example.com'), // @ doubled - - array('()[]\;:,<>@example.com'), // invalid characters - array('abc(def@example.com'), // invalid character ( - array('abc)def@example.com'), // invalid character ) - array('abc[def@example.com'), // invalid character [ - array('abc]def@example.com'), // invalid character ] - array('abc\def@example.com'), // invalid character \ - array('abc;def@example.com'), // invalid character ; - array('abc:def@example.com'), // invalid character : - array('abc,def@example.com'), // invalid character , - array('abcdef@example.com'), // invalid character > - - // http://fightingforalostcause.net/misc/2006/compare-email-regex.php - array('missingDomain@.com'), - array('@missingLocal.org'), - array('missingatSign.net'), - array('missingDot@com'), - array('two@@signs.com'), - array('colonButNoPort@127.0.0.1:'), - array(''), - array('someone-else@127.0.0.1.26'), - array('.localStartsWithDot@domain.com'), - array('localEndsWithDot.@domain.com'), - array('two..consecutiveDots@domain.com'), - array('domainStartsWithDash@-domain.com'), - array('domainEndsWithDash@domain-.com'), - array('numbersInTLD@domain.c0m'), - array('missingTLD@domain.'), - array('! "#$%(),/;<>[]`|@invalidCharsInLocal.org'), - array('invalidCharsInDomain@! "#$%(),/;<>_[]`|.org'), - array('local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'), - ); - } - - /** - * @dataProvider positive_match_data - */ - public function test_positive_match($email) - { - $this->assertEquals(1, preg_match($this->regex, $email)); - } - - /** - * @dataProvider negative_match_data - */ - public function test_negative_match($email) - { - $this->assertEquals(0, preg_match($this->regex, $email)); - } -} - diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php new file mode 100644 index 0000000000..5d6e207cbb --- /dev/null +++ b/tests/regex/email_test.php @@ -0,0 +1,118 @@ +regex = '#^' . get_preg_expression('email') . '$#i'; + } + + public function positive_match_data() + { + return array( + array('nobody@phpbb.com'), + array('Nobody@sub.phpbb.com'), + array('alice.bob@foo.phpbb.com'), + array('alice-foo@bar.phpbb.com'), + array('alice_foo@bar.phpbb.com'), + array('alice+tag@foo.phpbb.com'), + array('alice&tag@foo.phpbb.com'), + + //array('"John Doe"@example.com'), + //array('Alice@[192.168.2.1]'), // IPv4 + //array('Bob@[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]'), // IPv6 + + // http://fightingforalostcause.net/misc/2006/compare-email-regex.php + array('l3tt3rsAndNumb3rs@domain.com'), + array('has-dash@domain.com'), + array('hasApostrophe.o\'leary@domain.org'), + array('uncommonTLD@domain.museum'), + array('uncommonTLD@domain.travel'), + array('uncommonTLD@domain.mobi'), + array('countryCodeTLD@domain.uk'), + array('countryCodeTLD@domain.rw'), + array('numbersInDomain@911.com'), + array('underscore_inLocal@domain.net'), + array('IPInsteadOfDomain@127.0.0.1'), + array('IPAndPort@127.0.0.1:25'), + array('subdomain@sub.domain.com'), + array('local@dash-inDomain.com'), + array('dot.inLocal@foo.com'), + array('a@singleLetterLocal.org'), + array('singleLetterDomain@x.org'), + array('&*=?^+{}\'~@validCharsInLocal.net'), + array('foor@bar.newTLD'), + ); + } + + public function negative_match_data() + { + return array( + array('foo.example.com'), // @ is missing + array('.foo.example.com'), // . as first character + array('Foo.@example.com'), // . is last in local part + array('foo..123@example.com'), // . doubled + array('a@b@c@example.com'), // @ doubled + + array('()[]\;:,<>@example.com'), // invalid characters + array('abc(def@example.com'), // invalid character ( + array('abc)def@example.com'), // invalid character ) + array('abc[def@example.com'), // invalid character [ + array('abc]def@example.com'), // invalid character ] + array('abc\def@example.com'), // invalid character \ + array('abc;def@example.com'), // invalid character ; + array('abc:def@example.com'), // invalid character : + array('abc,def@example.com'), // invalid character , + array('abcdef@example.com'), // invalid character > + + // http://fightingforalostcause.net/misc/2006/compare-email-regex.php + array('missingDomain@.com'), + array('@missingLocal.org'), + array('missingatSign.net'), + array('missingDot@com'), + array('two@@signs.com'), + array('colonButNoPort@127.0.0.1:'), + array(''), + array('someone-else@127.0.0.1.26'), + array('.localStartsWithDot@domain.com'), + array('localEndsWithDot.@domain.com'), + array('two..consecutiveDots@domain.com'), + array('domainStartsWithDash@-domain.com'), + array('domainEndsWithDash@domain-.com'), + array('numbersInTLD@domain.c0m'), + array('missingTLD@domain.'), + array('! "#$%(),/;<>[]`|@invalidCharsInLocal.org'), + array('invalidCharsInDomain@! "#$%(),/;<>_[]`|.org'), + array('local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'), + ); + } + + /** + * @dataProvider positive_match_data + */ + public function test_positive_match($email) + { + $this->assertEquals(1, preg_match($this->regex, $email)); + } + + /** + * @dataProvider negative_match_data + */ + public function test_negative_match($email) + { + $this->assertEquals(0, preg_match($this->regex, $email)); + } +} + diff --git a/tests/regex/ipv4.php b/tests/regex/ipv4.php deleted file mode 100644 index 735a2c4384..0000000000 --- a/tests/regex/ipv4.php +++ /dev/null @@ -1,71 +0,0 @@ -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)); - } -} - 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 @@ +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)); + } +} + diff --git a/tests/regex/ipv6.php b/tests/regex/ipv6.php deleted file mode 100644 index 187588f861..0000000000 --- a/tests/regex/ipv6.php +++ /dev/null @@ -1,142 +0,0 @@ -regex = get_preg_expression('ipv6'); - } - - public function positive_match_data() - { - return array( - // Full length IPv6 address - array('2001:0db8:85a3:0000:0000:8a2e:0370:1337'), - array('0000:0000:0000:0000:0000:0000:0000:0001'), - array('3FFE:0b00:0000:0000:0001:0000:0000:000a'), - array('3ffe:0b00:0000:0000:0001:0000:0000:000a'), - array('2002:0db8:0000:0000:0000:dead:1337:d00d'), - - // No leading zeroes in the group - array('2001:db8:85a3:0:0:8a2e:370:1337'), - array('2001:db8:85a3:c:d:8a2e:370:1337'), - - // Consecutive all-zero groups - array('2001:db8:85a3::8a2e:370:1337'), - array('1::2:3:4:5:6:7'), - array('1::2:3:4:5:6'), - array('1::2:3:4:5'), - array('1::2:3:4'), - array('1::2:3'), - array('1::2'), - - // Last 32bit in dotted quad notation - array('2001:db8:0:1::192.168.0.2'), - - // IPv4-compatible IPv6 address - array('::13.1.68.3'), - array('0:0:0:0:0:0:13.1.68.3'), - - // IPv4-mapped IPv6 address - array('::ffff:c000:280'), - array('::ffff:c000:0280'), - array('::ffff:192.0.2.128'), - array('0:0:0:0:0:ffff:c000:280'), - array('0:0:0:0:0:ffff:c000:0280'), - array('0:0:0:0:0:ffff:192.0.2.128'), - array('0000:0000:0000:0000:0000:ffff:c000:280'), - array('0000:0000:0000:0000:0000:ffff:c000:0280'), - array('0000:0000:0000:0000:0000:ffff:192.0.2.128'), - - // No trailing zeroes - array('fe80::'), - array('2002::'), - array('2001:db8::'), - array('2001:0db8:1234::'), - array('1:2:3:4:5:6::'), - array('1:2:3:4:5::'), - array('1:2:3:4::'), - array('1:2:3::'), - array('1:2::'), - - // No leading zeroes - array('::2:3:4:5:6:7:8'), - array('::2:3:4:5:6:7'), - array('::2:3:4:5:6'), - array('::2:3:4:5'), - array('::2:3:4'), - array('::2:3'), - array('::1'), - array('::8'), - array('::c'), - array('::abcd'), - - // All zeroes - array('::'), - array('0:0:0:0:0:0:0:0'), - array('0000:0000:0000:0000:0000:0000:0000:0000'), - - // More tests - array('2::10'), - array('0:0::0:0:1'), - array('0:0:0:0:0:0:0:1'), - array('::ffff:0:0'), - ); - } - - public function negative_match_data() - { - return array( - // Empty address - array(''), - - // IPv4 address - array('192.168.0.2'), - - // Out of scope - array('abcd:efgh:0000::0'), - array('::ffff:192.168.255.256'), - - // Double :: - array('2001::23de::2002'), - array('3ffe:b00::1::b'), - array('::1111:2222:3333:4444:5555:6666::'), - - // Too many blocks - array('2001:0db8:85a3:08d3:1319:8a2e:0370:1337:4430'), - - // More tests - array('02001:0000:1234:0000:0000:C1C0:ABCD:9876'), - array('2001:0000:1234: 0000:0000:C1C0:ABCD:9876'), - array('::ffff:192x168.255.255'), - ); - } - - /** - * @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)); - } -} - diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php new file mode 100644 index 0000000000..187588f861 --- /dev/null +++ b/tests/regex/ipv6_test.php @@ -0,0 +1,142 @@ +regex = get_preg_expression('ipv6'); + } + + public function positive_match_data() + { + return array( + // Full length IPv6 address + array('2001:0db8:85a3:0000:0000:8a2e:0370:1337'), + array('0000:0000:0000:0000:0000:0000:0000:0001'), + array('3FFE:0b00:0000:0000:0001:0000:0000:000a'), + array('3ffe:0b00:0000:0000:0001:0000:0000:000a'), + array('2002:0db8:0000:0000:0000:dead:1337:d00d'), + + // No leading zeroes in the group + array('2001:db8:85a3:0:0:8a2e:370:1337'), + array('2001:db8:85a3:c:d:8a2e:370:1337'), + + // Consecutive all-zero groups + array('2001:db8:85a3::8a2e:370:1337'), + array('1::2:3:4:5:6:7'), + array('1::2:3:4:5:6'), + array('1::2:3:4:5'), + array('1::2:3:4'), + array('1::2:3'), + array('1::2'), + + // Last 32bit in dotted quad notation + array('2001:db8:0:1::192.168.0.2'), + + // IPv4-compatible IPv6 address + array('::13.1.68.3'), + array('0:0:0:0:0:0:13.1.68.3'), + + // IPv4-mapped IPv6 address + array('::ffff:c000:280'), + array('::ffff:c000:0280'), + array('::ffff:192.0.2.128'), + array('0:0:0:0:0:ffff:c000:280'), + array('0:0:0:0:0:ffff:c000:0280'), + array('0:0:0:0:0:ffff:192.0.2.128'), + array('0000:0000:0000:0000:0000:ffff:c000:280'), + array('0000:0000:0000:0000:0000:ffff:c000:0280'), + array('0000:0000:0000:0000:0000:ffff:192.0.2.128'), + + // No trailing zeroes + array('fe80::'), + array('2002::'), + array('2001:db8::'), + array('2001:0db8:1234::'), + array('1:2:3:4:5:6::'), + array('1:2:3:4:5::'), + array('1:2:3:4::'), + array('1:2:3::'), + array('1:2::'), + + // No leading zeroes + array('::2:3:4:5:6:7:8'), + array('::2:3:4:5:6:7'), + array('::2:3:4:5:6'), + array('::2:3:4:5'), + array('::2:3:4'), + array('::2:3'), + array('::1'), + array('::8'), + array('::c'), + array('::abcd'), + + // All zeroes + array('::'), + array('0:0:0:0:0:0:0:0'), + array('0000:0000:0000:0000:0000:0000:0000:0000'), + + // More tests + array('2::10'), + array('0:0::0:0:1'), + array('0:0:0:0:0:0:0:1'), + array('::ffff:0:0'), + ); + } + + public function negative_match_data() + { + return array( + // Empty address + array(''), + + // IPv4 address + array('192.168.0.2'), + + // Out of scope + array('abcd:efgh:0000::0'), + array('::ffff:192.168.255.256'), + + // Double :: + array('2001::23de::2002'), + array('3ffe:b00::1::b'), + array('::1111:2222:3333:4444:5555:6666::'), + + // Too many blocks + array('2001:0db8:85a3:08d3:1319:8a2e:0370:1337:4430'), + + // More tests + array('02001:0000:1234:0000:0000:C1C0:ABCD:9876'), + array('2001:0000:1234: 0000:0000:C1C0:ABCD:9876'), + array('::ffff:192x168.255.255'), + ); + } + + /** + * @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)); + } +} + diff --git a/tests/regex/url.php b/tests/regex/url.php deleted file mode 100644 index 246cbf549c..0000000000 --- a/tests/regex/url.php +++ /dev/null @@ -1,33 +0,0 @@ -assertEquals($expected, preg_match('#^' . get_preg_expression('url') . '$#i', $url)); - } -} diff --git a/tests/regex/url_test.php b/tests/regex/url_test.php new file mode 100644 index 0000000000..246cbf549c --- /dev/null +++ b/tests/regex/url_test.php @@ -0,0 +1,33 @@ +assertEquals($expected, preg_match('#^' . get_preg_expression('url') . '$#i', $url)); + } +} -- cgit v1.2.1