Add pear modules, mail and net_smtp via composer (#93)

Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
Thilina Hasantha
2018-01-08 23:13:43 +01:00
committed by GitHub
parent 359e3f8382
commit e7792e7d79
2349 changed files with 117270 additions and 83170 deletions

View File

@@ -0,0 +1,25 @@
--TEST--
Mail: Test for bug #13659
--FILE--
<?php
//require_once dirname(__FILE__) . '/../Mail/RFC822.php';
require_once 'Mail/RFC822.php';
require_once 'PEAR.php';
$address = '"Test Student" <test@mydomain.com> (test)';
$parser = new Mail_RFC822();
$result = $parser->parseAddressList($address, 'anydomain.com', TRUE);
if (!PEAR::isError($result) && is_array($result) && is_object($result[0]))
if ($result[0]->personal == '"Test Student"' &&
$result[0]->mailbox == "test" &&
$result[0]->host == "mydomain.com" &&
is_array($result[0]->comment) && $result[0]->comment[0] == 'test')
{
print("OK");
}
?>
--EXPECT--
OK

View File

@@ -0,0 +1,33 @@
--TEST--
Mail: Test for bug #9137
--FILE--
<?php
require_once dirname(__FILE__) . '/../Mail/RFC822.php';
require_once 'PEAR.php';
$addresses = array(
array('name' => 'John Doe', 'email' => 'test@example.com'),
array('name' => 'John Doe\\', 'email' => 'test@example.com'),
array('name' => 'John "Doe', 'email' => 'test@example.com'),
array('name' => 'John "Doe\\', 'email' => 'test@example.com'),
);
for ($i = 0; $i < count($addresses); $i++) {
// construct the address
$address = "\"" . addslashes($addresses[$i]['name']) . "\" ".
"<".$addresses[$i]['email'].">";
$parsedAddresses = Mail_RFC822::parseAddressList($address);
if (is_a($parsedAddresses, 'PEAR_Error')) {
echo $address." :: Failed to validate\n";
} else {
echo $address." :: Parsed\n";
}
}
--EXPECT--
"John Doe" <test@example.com> :: Parsed
"John Doe\\" <test@example.com> :: Parsed
"John \"Doe" <test@example.com> :: Parsed
"John \"Doe\\" <test@example.com> :: Parsed

View File

@@ -0,0 +1,35 @@
--TEST--
Mail: Test for bug #9137, take 2
--FILE--
<?php
require_once dirname(__FILE__) . '/../Mail/RFC822.php';
require_once 'PEAR.php';
$addresses = array(
array('raw' => '"John Doe" <test@example.com>'),
array('raw' => '"John Doe' . chr(92) . '" <test@example.com>'),
array('raw' => '"John Doe' . chr(92) . chr(92) . '" <test@example.com>'),
array('raw' => '"John Doe' . chr(92) . chr(92) . chr(92) . '" <test@example.com>'),
array('raw' => '"John Doe' . chr(92) . chr(92) . chr(92) . chr(92) . '" <test@example.com>'),
array('raw' => '"John Doe <test@example.com>'),
);
for ($i = 0; $i < count($addresses); $i++) {
// construct the address
$address = $addresses[$i]['raw'];
$parsedAddresses = Mail_RFC822::parseAddressList($address);
if (PEAR::isError($parsedAddresses)) {
echo $address." :: Failed to validate\n";
} else {
echo $address." :: Parsed\n";
}
}
--EXPECT--
"John Doe" <test@example.com> :: Parsed
"John Doe\" <test@example.com> :: Failed to validate
"John Doe\\" <test@example.com> :: Parsed
"John Doe\\\" <test@example.com> :: Failed to validate
"John Doe\\\\" <test@example.com> :: Parsed
"John Doe <test@example.com> :: Failed to validate

View File

@@ -0,0 +1,8 @@
clean:
rm -f *.log *.php *.diff *.exp *.out
test:
cd .. && pear run-tests tests/*.phpt && cd tests;

View File

@@ -0,0 +1,11 @@
--TEST--
Mail_RFC822::parseAddressList does not accept RFC-valid group syntax
--FILE--
<?php
require "Mail/RFC822.php";
var_dump(Mail_RFC822::parseAddressList("empty-group:;","invalid",false,false));
--EXPECT--
array(0) {
}

View File

@@ -0,0 +1,19 @@
--TEST--
Mail_RFC822::parseAddressList invalid periods in mail address
--FILE--
<?php
require "Mail/RFC822.php";
$result[] = Mail_RFC822::parseAddressList('.name@example.com');
$result[] = Mail_RFC822::parseAddressList('name.@example.com');
$result[] = Mail_RFC822::parseAddressList('name..name@example.com');
foreach ($result as $r) {
if (is_a($r, 'PEAR_Error')) {
echo "OK\n";
}
}
--EXPECT--
OK
OK
OK

View File

@@ -0,0 +1,107 @@
--TEST--
Mail_RFC822: Address Parsing
--FILE--
<?php
require_once 'Mail/RFC822.php';
$parser = new Mail_RFC822();
/* A simple, bare address. */
$address = 'user@example.com';
print_r($parser->parseAddressList($address, null, true, true));
/* Address groups. */
$address = 'My Group: "Richard" <richard@localhost> (A comment), ted@example.com (Ted Bloggs), Barney;';
print_r($parser->parseAddressList($address, null, true, true));
/* A valid address with spaces in the local part. */
$address = '<"Jon Parise"@php.net>';
print_r($parser->parseAddressList($address, null, true, true));
/* An invalid address with spaces in the local part. */
$address = '<Jon Parise@php.net>';
$result = $parser->parseAddressList($address, null, true, true);
if (is_a($result, 'PEAR_Error')) echo $result->getMessage() . "\n";
/* A valid address with an uncommon TLD. */
$address = 'jon@host.longtld';
$result = $parser->parseAddressList($address, null, true, true);
if (is_a($result, 'PEAR_Error')) echo $result->getMessage() . "\n";
--EXPECT--
Array
(
[0] => stdClass Object
(
[personal] =>
[comment] => Array
(
)
[mailbox] => user
[host] => example.com
)
)
Array
(
[0] => stdClass Object
(
[groupname] => My Group
[addresses] => Array
(
[0] => stdClass Object
(
[personal] => "Richard"
[comment] => Array
(
[0] => A comment
)
[mailbox] => richard
[host] => localhost
)
[1] => stdClass Object
(
[personal] =>
[comment] => Array
(
[0] => Ted Bloggs
)
[mailbox] => ted
[host] => example.com
)
[2] => stdClass Object
(
[personal] =>
[comment] => Array
(
)
[mailbox] => Barney
[host] => localhost
)
)
)
)
Array
(
[0] => stdClass Object
(
[personal] =>
[comment] => Array
(
)
[mailbox] => "Jon Parise"
[host] => php.net
)
)
Validation failed for: <Jon Parise@php.net>

View File

@@ -0,0 +1,30 @@
--TEST--
Mail: SMTP Error Reporting
--SKIPIF--
<?php
require_once 'PEAR/Registry.php';
$registry = new PEAR_Registry();
if (!$registry->packageExists('Net_SMTP')) die("skip\n");
--FILE--
<?php
require_once 'Mail.php';
/* Reference a bogus SMTP server address to guarantee a connection failure. */
$params = array('host' => 'bogus.host.tld');
/* Create our SMTP-based mailer object. */
$mailer = Mail::factory('smtp', $params);
/* Attempt to send an empty message in order to trigger an error. */
$e = $mailer->send(array(), array(), '');
if (is_a($e, 'PEAR_Error')) {
$err = $e->getMessage();
if (preg_match('/Failed to connect to bogus.host.tld:25 \[SMTP: Failed to connect socket:.*/i', $err)) {
echo "OK";
}
}
--EXPECT--
OK

View File

@@ -0,0 +1,17 @@
<?php
require_once '../Mail/RFC822.php';
$address_string = '"Joe Doe \(from Somewhere\)" <doe@example.com>, postmaster@example.com, root';
// $address_string = "Joe Doe from Somewhere <doe@example.com>, postmaster@example.com, root";
echo $address_string . "\n";
$address_array = Mail_RFC822::parseAddressList($address_string, "example.com");
if (!is_array($address_array) || count($address_array) < 1) {
die("something is wrong\n");
}
foreach ($address_array as $val) {
echo "mailbox : " . $val->mailbox . "\n";
echo "host : " . $val->host . "\n";
echo "personal: " . $val->personal . "\n";
}
print_r($address_array);