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+
10+
11+
12+
13+
14+
15+
16+
17+
18+
'wrong-address-with@@@@-remove_me-and-some-i-hate_SPAM-stuff',
19+
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) "[email protected]"
33+
[1]=>
34+
string(22) "[email protected]"
35+
[2]=>
36+
string(22) "[email protected]"
37+
[3]=>
38+
string(22) "[email protected]"
39+
[4]=>
40+
string(22) "[email protected]"
41+
[5]=>
42+
string(19) "[email protected]"
43+
[6]=>
44+
string(23) "[email protected]"
45+
[7]=>
46+
string(23) "[email protected]"
47+
[8]=>
48+
string(20) "[email protected]"
49+
[9]=>
50+
string(35) "wrong-address-with@@@@and-somestuff"
51+
[10]=>
52+
string(33) "[email protected]"
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+
10+
11+
12+
13+
14+
15+
16+
17+
18+
'wrong-address-with@@@@-remove_me-and-some-i-hate_SPAM-stuff',
19+
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) "[email protected]"
33+
[1]=>
34+
string(35) "[email protected]"
35+
[3]=>
36+
string(30) "[email protected]"
37+
[5]=>
38+
string(19) "[email protected]"
39+
[7]=>
40+
string(23) "[email protected]"
41+
[8]=>
42+
string(20) "[email protected]"
43+
}

0 commit comments

Comments
 (0)