Skip to content

Commit d31e187

Browse files
authored
Fix: Replace script with tests
Closes GH-631.
1 parent acb371e commit d31e187

File tree

3 files changed

+96
-28
lines changed

3 files changed

+96
-28
lines changed

include/check_email_func.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/clean-anti-spam.phpt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
clean_AntiSPAM() removes spam terms
3+
--FILE--
4+
<?php
5+
6+
require_once __DIR__ . '/../include/email-validation.inc';
7+
8+
$emails = array (
9+
'asasasd324324@php.net',
10+
'jcastagnetto-delete-this-@yahoo.com',
11+
'jcastagnetto-i-hate-spam@NOSPAMyahoo.com',
12+
'jcastagnetto-NO-SPAM@yahoo.com',
13+
'jcastagnetto@NoSpam-yahoo.com',
14+
'jesusmc@scripps.edu',
15+
'jmcastagnetto@chek2.com',
16+
'jmcastagnetto@yahoo.com',
17+
'some-wrong@asdas.com',
18+
'wrong-address-with@@@@-remove_me-and-some-i-hate_SPAM-stuff',
19+
'wrong-email-address@lists.php.net',
20+
);
21+
22+
$cleanedEmails = array_map(static function (string $email): string {
23+
return clean_AntiSPAM($email);
24+
}, $emails);
25+
26+
var_dump($cleanedEmails);
27+
28+
?>
29+
--EXPECT--
30+
array(11) {
31+
[0]=>
32+
string(21) "asasasd324324@php.net"
33+
[1]=>
34+
string(22) "jcastagnetto@yahoo.com"
35+
[2]=>
36+
string(22) "jcastagnetto@yahoo.com"
37+
[3]=>
38+
string(22) "jcastagnetto@yahoo.com"
39+
[4]=>
40+
string(22) "jcastagnetto@yahoo.com"
41+
[5]=>
42+
string(19) "jesusmc@scripps.edu"
43+
[6]=>
44+
string(23) "jmcastagnetto@chek2.com"
45+
[7]=>
46+
string(23) "jmcastagnetto@yahoo.com"
47+
[8]=>
48+
string(20) "some-wrong@asdas.com"
49+
[9]=>
50+
string(35) "wrong-address-with@@@@and-somestuff"
51+
[10]=>
52+
string(33) "wrong-email-address@lists.php.net"
53+
}

tests/is-emailable-address.phpt

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
is_emailable_address() returns whether email is emailable
3+
--FILE--
4+
<?php
5+
6+
require_once __DIR__ . '/../include/email-validation.inc';
7+
8+
$emails = array(
9+
'asasasd324324@php.net',
10+
'jcastagnetto-delete-this-@yahoo.com',
11+
'jcastagnetto-i-hate-spam@NOSPAMyahoo.com',
12+
'jcastagnetto-NO-SPAM@yahoo.com',
13+
'jcastagnetto@NoSpam-yahoo.com',
14+
'jesusmc@scripps.edu',
15+
'jmcastagnetto@chek2.com',
16+
'jmcastagnetto@yahoo.com',
17+
'some-wrong@asdas.com',
18+
'wrong-address-with@@@@-remove_me-and-some-i-hate_SPAM-stuff',
19+
'wrong-email-address@lists.php.net',
20+
);
21+
22+
$emailsThatAreEmailableAddresses = array_filter($emails, static function (string $email): bool {
23+
return is_emailable_address($email);
24+
});
25+
26+
var_dump($emailsThatAreEmailableAddresses);
27+
28+
?>
29+
--EXPECT--
30+
array(6) {
31+
[0]=>
32+
string(21) "asasasd324324@php.net"
33+
[1]=>
34+
string(35) "jcastagnetto-delete-this-@yahoo.com"
35+
[3]=>
36+
string(30) "jcastagnetto-NO-SPAM@yahoo.com"
37+
[5]=>
38+
string(19) "jesusmc@scripps.edu"
39+
[7]=>
40+
string(23) "jmcastagnetto@yahoo.com"
41+
[8]=>
42+
string(20) "some-wrong@asdas.com"
43+
}

0 commit comments

Comments
 (0)