Commit 0ee13881 by Juliper

Bagian II

parent 9593781c
<?php
namespace Illuminate\Support\Facades;
/**
* @see \Illuminate\Contracts\Broadcasting\Factory
*/
class Broadcast extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'Illuminate\Contracts\Broadcasting\Factory';
}
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Sends Messages using the mail() function.
*
* It is advised that users do not use this transport if at all possible
* since a number of plugin features cannot be used in conjunction with this
* transport due to the internal interface in PHP itself.
*
* The level of error reporting with this transport is incredibly weak, again
* due to limitations of PHP's internal mail() function. You'll get an
* all-or-nothing result from sending.
*
* @author Chris Corbyn
*
* @deprecated since 5.4.5 (to be removed in 6.0)
*/
class Swift_Transport_MailTransport implements Swift_Transport
{
/** Additional parameters to pass to mail() */
private $_extraParams = '-f%s';
/** The event dispatcher from the plugin API */
private $_eventDispatcher;
/** An invoker that calls the mail() function */
private $_invoker;
/**
* Create a new MailTransport with the $log.
*
* @param Swift_Transport_MailInvoker $invoker
* @param Swift_Events_EventDispatcher $eventDispatcher
*/
public function __construct(Swift_Transport_MailInvoker $invoker, Swift_Events_EventDispatcher $eventDispatcher)
{
@trigger_error(sprintf('The %s class is deprecated since version 5.4.5 and will be removed in 6.0. Use the Sendmail or SMTP transport instead.', __CLASS__), E_USER_DEPRECATED);
$this->_invoker = $invoker;
$this->_eventDispatcher = $eventDispatcher;
}
/**
* Not used.
*/
public function isStarted()
{
return false;
}
/**
* Not used.
*/
public function start()
{
}
/**
* Not used.
*/
public function stop()
{
}
/**
* Set the additional parameters used on the mail() function.
*
* This string is formatted for sprintf() where %s is the sender address.
*
* @param string $params
*
* @return Swift_Transport_MailTransport
*/
public function setExtraParams($params)
{
$this->_extraParams = $params;
return $this;
}
/**
* Get the additional parameters used on the mail() function.
*
* This string is formatted for sprintf() where %s is the sender address.
*
* @return string
*/
public function getExtraParams()
{
return $this->_extraParams;
}
/**
* Send the given Message.
*
* Recipient/sender data will be retrieved from the Message API.
* The return value is the number of recipients who were accepted for delivery.
*
* @param Swift_Mime_Message $message
* @param string[] $failedRecipients An array of failures by-reference
*
* @return int
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
$failedRecipients = (array) $failedRecipients;
if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
$this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
if ($evt->bubbleCancelled()) {
return 0;
}
}
$count = (
count((array) $message->getTo())
+ count((array) $message->getCc())
+ count((array) $message->getBcc())
);
$toHeader = $message->getHeaders()->get('To');
$subjectHeader = $message->getHeaders()->get('Subject');
if (0 === $count) {
$this->_throwException(new Swift_TransportException('Cannot send message without a recipient'));
}
$to = $toHeader ? $toHeader->getFieldBody() : '';
$subject = $subjectHeader ? $subjectHeader->getFieldBody() : '';
$reversePath = $this->_getReversePath($message);
// Remove headers that would otherwise be duplicated
$message->getHeaders()->remove('To');
$message->getHeaders()->remove('Subject');
$messageStr = $message->toString();
if ($toHeader) {
$message->getHeaders()->set($toHeader);
}
$message->getHeaders()->set($subjectHeader);
// Separate headers from body
if (false !== $endHeaders = strpos($messageStr, "\r\n\r\n")) {
$headers = substr($messageStr, 0, $endHeaders)."\r\n"; //Keep last EOL
$body = substr($messageStr, $endHeaders + 4);
} else {
$headers = $messageStr."\r\n";
$body = '';
}
unset($messageStr);
if ("\r\n" != PHP_EOL) {
// Non-windows (not using SMTP)
$headers = str_replace("\r\n", PHP_EOL, $headers);
$subject = str_replace("\r\n", PHP_EOL, $subject);
$body = str_replace("\r\n", PHP_EOL, $body);
$to = str_replace("\r\n", PHP_EOL, $to);
} else {
// Windows, using SMTP
$headers = str_replace("\r\n.", "\r\n..", $headers);
$subject = str_replace("\r\n.", "\r\n..", $subject);
$body = str_replace("\r\n.", "\r\n..", $body);
$to = str_replace("\r\n.", "\r\n..", $to);
}
if ($this->_invoker->mail($to, $subject, $body, $headers, $this->_formatExtraParams($this->_extraParams, $reversePath))) {
if ($evt) {
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
$evt->setFailedRecipients($failedRecipients);
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
}
} else {
$failedRecipients = array_merge(
$failedRecipients,
array_keys((array) $message->getTo()),
array_keys((array) $message->getCc()),
array_keys((array) $message->getBcc())
);
if ($evt) {
$evt->setResult(Swift_Events_SendEvent::RESULT_FAILED);
$evt->setFailedRecipients($failedRecipients);
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
}
$message->generateId();
$count = 0;
}
return $count;
}
/**
* Register a plugin.
*
* @param Swift_Events_EventListener $plugin
*/
public function registerPlugin(Swift_Events_EventListener $plugin)
{
$this->_eventDispatcher->bindEventListener($plugin);
}
/** Throw a TransportException, first sending it to any listeners */
protected function _throwException(Swift_TransportException $e)
{
if ($evt = $this->_eventDispatcher->createTransportExceptionEvent($this, $e)) {
$this->_eventDispatcher->dispatchEvent($evt, 'exceptionThrown');
if (!$evt->bubbleCancelled()) {
throw $e;
}
} else {
throw $e;
}
}
/** Determine the best-use reverse path for this message */
private function _getReversePath(Swift_Mime_Message $message)
{
$return = $message->getReturnPath();
$sender = $message->getSender();
$from = $message->getFrom();
$path = null;
if (!empty($return)) {
$path = $return;
} elseif (!empty($sender)) {
$keys = array_keys($sender);
$path = array_shift($keys);
} elseif (!empty($from)) {
$keys = array_keys($from);
$path = array_shift($keys);
}
return $path;
}
/**
* Fix CVE-2016-10074 by disallowing potentially unsafe shell characters.
*
* Note that escapeshellarg and escapeshellcmd are inadequate for our purposes, especially on Windows.
*
* @param string $string The string to be validated
*
* @return bool
*/
private function _isShellSafe($string)
{
// Future-proof
if (escapeshellcmd($string) !== $string || !in_array(escapeshellarg($string), array("'$string'", "\"$string\""))) {
return false;
}
$length = strlen($string);
for ($i = 0; $i < $length; ++$i) {
$c = $string[$i];
// All other characters have a special meaning in at least one common shell, including = and +.
// Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here.
// Note that this does permit non-Latin alphanumeric characters based on the current locale.
if (!ctype_alnum($c) && strpos('@_-.', $c) === false) {
return false;
}
}
return true;
}
/**
* Return php mail extra params to use for invoker->mail.
*
* @param $extraParams
* @param $reversePath
*
* @return string|null
*/
private function _formatExtraParams($extraParams, $reversePath)
{
if (false !== strpos($extraParams, '-f%s')) {
if (empty($reversePath) || false === $this->_isShellSafe($reversePath)) {
$extraParams = str_replace('-f%s', '', $extraParams);
} else {
$extraParams = sprintf($extraParams, $reversePath);
}
}
return !empty($extraParams) ? $extraParams : null;
}
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2009 Fabien Potencier <fabien.potencier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Pretends messages have been sent, but just ignores them.
*
* @author Fabien Potencier
*/
class Swift_Transport_NullTransport implements Swift_Transport
{
/** The event dispatcher from the plugin API */
private $_eventDispatcher;
/**
* Constructor.
*/
public function __construct(Swift_Events_EventDispatcher $eventDispatcher)
{
$this->_eventDispatcher = $eventDispatcher;
}
/**
* Tests if this Transport mechanism has started.
*
* @return bool
*/
public function isStarted()
{
return true;
}
/**
* Starts this Transport mechanism.
*/
public function start()
{
}
/**
* Stops this Transport mechanism.
*/
public function stop()
{
}
/**
* Sends the given message.
*
* @param Swift_Mime_Message $message
* @param string[] $failedRecipients An array of failures by-reference
*
* @return int The number of sent emails
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
$this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
if ($evt->bubbleCancelled()) {
return 0;
}
}
if ($evt) {
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
}
$count = (
count((array) $message->getTo())
+ count((array) $message->getCc())
+ count((array) $message->getBcc())
);
return $count;
}
/**
* Register a plugin.
*
* @param Swift_Events_EventListener $plugin
*/
public function registerPlugin(Swift_Events_EventListener $plugin)
{
$this->_eventDispatcher->bindEventListener($plugin);
}
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* SendmailTransport for sending mail through a Sendmail/Postfix (etc..) binary.
*
* Supported modes are -bs and -t, with any additional flags desired.
* It is advised to use -bs mode since error reporting with -t mode is not
* possible.
*
* @author Chris Corbyn
*/
class Swift_Transport_SendmailTransport extends Swift_Transport_AbstractSmtpTransport
{
/**
* Connection buffer parameters.
*
* @var array
*/
private $_params = array(
'timeout' => 30,
'blocking' => 1,
'command' => '/usr/sbin/sendmail -bs',
'type' => Swift_Transport_IoBuffer::TYPE_PROCESS,
);
/**
* Create a new SendmailTransport with $buf for I/O.
*
* @param Swift_Transport_IoBuffer $buf
* @param Swift_Events_EventDispatcher $dispatcher
*/
public function __construct(Swift_Transport_IoBuffer $buf, Swift_Events_EventDispatcher $dispatcher)
{
parent::__construct($buf, $dispatcher);
}
/**
* Start the standalone SMTP session if running in -bs mode.
*/
public function start()
{
if (false !== strpos($this->getCommand(), ' -bs')) {
parent::start();
}
}
/**
* Set the command to invoke.
*
* If using -t mode you are strongly advised to include -oi or -i in the flags.
* For example: /usr/sbin/sendmail -oi -t
* Swift will append a -f<sender> flag if one is not present.
*
* The recommended mode is "-bs" since it is interactive and failure notifications
* are hence possible.
*
* @param string $command
*
* @return Swift_Transport_SendmailTransport
*/
public function setCommand($command)
{
$this->_params['command'] = $command;
return $this;
}
/**
* Get the sendmail command which will be invoked.
*
* @return string
*/
public function getCommand()
{
return $this->_params['command'];
}
/**
* Send the given Message.
*
* Recipient/sender data will be retrieved from the Message API.
*
* The return value is the number of recipients who were accepted for delivery.
* NOTE: If using 'sendmail -t' you will not be aware of any failures until
* they bounce (i.e. send() will always return 100% success).
*
* @param Swift_Mime_Message $message
* @param string[] $failedRecipients An array of failures by-reference
*
* @return int
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
$failedRecipients = (array) $failedRecipients;
$command = $this->getCommand();
$buffer = $this->getBuffer();
$count = 0;
if (false !== strpos($command, ' -t')) {
if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
$this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
if ($evt->bubbleCancelled()) {
return 0;
}
}
if (false === strpos($command, ' -f')) {
$command .= ' -f'.escapeshellarg($this->_getReversePath($message));
}
$buffer->initialize(array_merge($this->_params, array('command' => $command)));
if (false === strpos($command, ' -i') && false === strpos($command, ' -oi')) {
$buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n.."));
} else {
$buffer->setWriteTranslations(array("\r\n" => "\n"));
}
$count = count((array) $message->getTo())
+ count((array) $message->getCc())
+ count((array) $message->getBcc())
;
$message->toByteStream($buffer);
$buffer->flushBuffers();
$buffer->setWriteTranslations(array());
$buffer->terminate();
if ($evt) {
$evt->setResult(Swift_Events_SendEvent::RESULT_SUCCESS);
$evt->setFailedRecipients($failedRecipients);
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
}
$message->generateId();
} elseif (false !== strpos($command, ' -bs')) {
$count = parent::send($message, $failedRecipients);
} else {
$this->_throwException(new Swift_TransportException(
'Unsupported sendmail command flags ['.$command.']. '.
'Must be one of "-bs" or "-t" but can include additional flags.'
));
}
return $count;
}
/** Get the params to initialize the buffer */
protected function _getBufferParams()
{
return $this->_params;
}
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* This is the implementation class for {@link Swift_Transport_MailInvoker}.
*
* @author Chris Corbyn
*/
class Swift_Transport_SimpleMailInvoker implements Swift_Transport_MailInvoker
{
/**
* Send mail via the mail() function.
*
* This method takes the same arguments as PHP mail().
*
* @param string $to
* @param string $subject
* @param string $body
* @param string $headers
* @param string $extraParams
*
* @return bool
*/
public function mail($to, $subject, $body, $headers = null, $extraParams = null)
{
if (!ini_get('safe_mode')) {
return @mail($to, $subject, $body, $headers, $extraParams);
}
return @mail($to, $subject, $body, $headers);
}
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Wraps an IoBuffer to send/receive SMTP commands/responses.
*
* @author Chris Corbyn
*/
interface Swift_Transport_SmtpAgent
{
/**
* Get the IoBuffer where read/writes are occurring.
*
* @return Swift_Transport_IoBuffer
*/
public function getBuffer();
/**
* Run a command against the buffer, expecting the given response codes.
*
* If no response codes are given, the response will not be validated.
* If codes are given, an exception will be thrown on an invalid response.
*
* @param string $command
* @param int[] $codes
* @param string[] $failures An array of failures by-reference
*/
public function executeCommand($command, $codes = array(), &$failures = null);
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2009 Fabien Potencier <fabien.potencier@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Stores Messages in a queue.
*
* @author Fabien Potencier
*/
class Swift_Transport_SpoolTransport implements Swift_Transport
{
/** The spool instance */
private $_spool;
/** The event dispatcher from the plugin API */
private $_eventDispatcher;
/**
* Constructor.
*/
public function __construct(Swift_Events_EventDispatcher $eventDispatcher, Swift_Spool $spool = null)
{
$this->_eventDispatcher = $eventDispatcher;
$this->_spool = $spool;
}
/**
* Sets the spool object.
*
* @param Swift_Spool $spool
*
* @return Swift_Transport_SpoolTransport
*/
public function setSpool(Swift_Spool $spool)
{
$this->_spool = $spool;
return $this;
}
/**
* Get the spool object.
*
* @return Swift_Spool
*/
public function getSpool()
{
return $this->_spool;
}
/**
* Tests if this Transport mechanism has started.
*
* @return bool
*/
public function isStarted()
{
return true;
}
/**
* Starts this Transport mechanism.
*/
public function start()
{
}
/**
* Stops this Transport mechanism.
*/
public function stop()
{
}
/**
* Sends the given message.
*
* @param Swift_Mime_Message $message
* @param string[] $failedRecipients An array of failures by-reference
*
* @return int The number of sent e-mail's
*/
public function send(Swift_Mime_Message $message, &$failedRecipients = null)
{
if ($evt = $this->_eventDispatcher->createSendEvent($this, $message)) {
$this->_eventDispatcher->dispatchEvent($evt, 'beforeSendPerformed');
if ($evt->bubbleCancelled()) {
return 0;
}
}
$success = $this->_spool->queueMessage($message);
if ($evt) {
$evt->setResult($success ? Swift_Events_SendEvent::RESULT_SPOOLED : Swift_Events_SendEvent::RESULT_FAILED);
$this->_eventDispatcher->dispatchEvent($evt, 'sendPerformed');
}
return 1;
}
/**
* Register a plugin.
*
* @param Swift_Events_EventListener $plugin
*/
public function registerPlugin(Swift_Events_EventListener $plugin)
{
$this->_eventDispatcher->bindEventListener($plugin);
}
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* A generic IoBuffer implementation supporting remote sockets and local processes.
*
* @author Chris Corbyn
*/
class Swift_Transport_StreamBuffer extends Swift_ByteStream_AbstractFilterableInputStream implements Swift_Transport_IoBuffer
{
/** A primary socket */
private $_stream;
/** The input stream */
private $_in;
/** The output stream */
private $_out;
/** Buffer initialization parameters */
private $_params = array();
/** The ReplacementFilterFactory */
private $_replacementFactory;
/** Translations performed on data being streamed into the buffer */
private $_translations = array();
/**
* Create a new StreamBuffer using $replacementFactory for transformations.
*
* @param Swift_ReplacementFilterFactory $replacementFactory
*/
public function __construct(Swift_ReplacementFilterFactory $replacementFactory)
{
$this->_replacementFactory = $replacementFactory;
}
/**
* Perform any initialization needed, using the given $params.
*
* Parameters will vary depending upon the type of IoBuffer used.
*
* @param array $params
*/
public function initialize(array $params)
{
$this->_params = $params;
switch ($params['type']) {
case self::TYPE_PROCESS:
$this->_establishProcessConnection();
break;
case self::TYPE_SOCKET:
default:
$this->_establishSocketConnection();
break;
}
}
/**
* Set an individual param on the buffer (e.g. switching to SSL).
*
* @param string $param
* @param mixed $value
*/
public function setParam($param, $value)
{
if (isset($this->_stream)) {
switch ($param) {
case 'timeout':
if ($this->_stream) {
stream_set_timeout($this->_stream, $value);
}
break;
case 'blocking':
if ($this->_stream) {
stream_set_blocking($this->_stream, 1);
}
}
}
$this->_params[$param] = $value;
}
public function startTLS()
{
return stream_socket_enable_crypto($this->_stream, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
}
/**
* Perform any shutdown logic needed.
*/
public function terminate()
{
if (isset($this->_stream)) {
switch ($this->_params['type']) {
case self::TYPE_PROCESS:
fclose($this->_in);
fclose($this->_out);
proc_close($this->_stream);
break;
case self::TYPE_SOCKET:
default:
fclose($this->_stream);
break;
}
}
$this->_stream = null;
$this->_out = null;
$this->_in = null;
}
/**
* Set an array of string replacements which should be made on data written
* to the buffer.
*
* This could replace LF with CRLF for example.
*
* @param string[] $replacements
*/
public function setWriteTranslations(array $replacements)
{
foreach ($this->_translations as $search => $replace) {
if (!isset($replacements[$search])) {
$this->removeFilter($search);
unset($this->_translations[$search]);
}
}
foreach ($replacements as $search => $replace) {
if (!isset($this->_translations[$search])) {
$this->addFilter(
$this->_replacementFactory->createFilter($search, $replace), $search
);
$this->_translations[$search] = true;
}
}
}
/**
* Get a line of output (including any CRLF).
*
* The $sequence number comes from any writes and may or may not be used
* depending upon the implementation.
*
* @param int $sequence of last write to scan from
*
* @throws Swift_IoException
*
* @return string
*/
public function readLine($sequence)
{
if (isset($this->_out) && !feof($this->_out)) {
$line = fgets($this->_out);
if (strlen($line) == 0) {
$metas = stream_get_meta_data($this->_out);
if ($metas['timed_out']) {
throw new Swift_IoException(
'Connection to '.
$this->_getReadConnectionDescription().
' Timed Out'
);
}
}
return $line;
}
}
/**
* Reads $length bytes from the stream into a string and moves the pointer
* through the stream by $length.
*
* If less bytes exist than are requested the remaining bytes are given instead.
* If no bytes are remaining at all, boolean false is returned.
*
* @param int $length
*
* @throws Swift_IoException
*
* @return string|bool
*/
public function read($length)
{
if (isset($this->_out) && !feof($this->_out)) {
$ret = fread($this->_out, $length);
if (strlen($ret) == 0) {
$metas = stream_get_meta_data($this->_out);
if ($metas['timed_out']) {
throw new Swift_IoException(
'Connection to '.
$this->_getReadConnectionDescription().
' Timed Out'
);
}
}
return $ret;
}
}
/** Not implemented */
public function setReadPointer($byteOffset)
{
}
/** Flush the stream contents */
protected function _flush()
{
if (isset($this->_in)) {
fflush($this->_in);
}
}
/** Write this bytes to the stream */
protected function _commit($bytes)
{
if (isset($this->_in)) {
$bytesToWrite = strlen($bytes);
$totalBytesWritten = 0;
while ($totalBytesWritten < $bytesToWrite) {
$bytesWritten = fwrite($this->_in, substr($bytes, $totalBytesWritten));
if (false === $bytesWritten || 0 === $bytesWritten) {
break;
}
$totalBytesWritten += $bytesWritten;
}
if ($totalBytesWritten > 0) {
return ++$this->_sequence;
}
}
}
/**
* Establishes a connection to a remote server.
*/
private function _establishSocketConnection()
{
$host = $this->_params['host'];
if (!empty($this->_params['protocol'])) {
$host = $this->_params['protocol'].'://'.$host;
}
$timeout = 15;
if (!empty($this->_params['timeout'])) {
$timeout = $this->_params['timeout'];
}
$options = array();
if (!empty($this->_params['sourceIp'])) {
$options['socket']['bindto'] = $this->_params['sourceIp'].':0';
}
if (isset($this->_params['stream_context_options'])) {
$options = array_merge($options, $this->_params['stream_context_options']);
}
$streamContext = stream_context_create($options);
$this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $streamContext);
if (false === $this->_stream) {
throw new Swift_TransportException(
'Connection could not be established with host '.$this->_params['host'].
' ['.$errstr.' #'.$errno.']'
);
}
if (!empty($this->_params['blocking'])) {
stream_set_blocking($this->_stream, 1);
} else {
stream_set_blocking($this->_stream, 0);
}
stream_set_timeout($this->_stream, $timeout);
$this->_in = &$this->_stream;
$this->_out = &$this->_stream;
}
/**
* Opens a process for input/output.
*/
private function _establishProcessConnection()
{
$command = $this->_params['command'];
$descriptorSpec = array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$pipes = array();
$this->_stream = proc_open($command, $descriptorSpec, $pipes);
stream_set_blocking($pipes[2], 0);
if ($err = stream_get_contents($pipes[2])) {
throw new Swift_TransportException(
'Process could not be started ['.$err.']'
);
}
$this->_in = &$pipes[0];
$this->_out = &$pipes[1];
}
private function _getReadConnectionDescription()
{
switch ($this->_params['type']) {
case self::TYPE_PROCESS:
return 'Process '.$this->_params['command'];
break;
case self::TYPE_SOCKET:
default:
$host = $this->_params['host'];
if (!empty($this->_params['protocol'])) {
$host = $this->_params['protocol'].'://'.$host;
}
$host .= ':'.$this->_params['port'];
return $host;
break;
}
}
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* TransportException thrown when an error occurs in the Transport subsystem.
*
* @author Chris Corbyn
*/
class Swift_TransportException extends Swift_IoException
{
/**
* Create a new TransportException with $message.
*
* @param string $message
* @param int $code
* @param Exception $previous
*/
public function __construct($message, $code = 0, Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
}
<?php
/*
* This file is part of SwiftMailer.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Utility Class allowing users to simply check expressions again Swift Grammar.
*
* @author Xavier De Cock <xdecock@gmail.com>
*/
class Swift_Validate
{
/**
* Grammar Object.
*
* @var Swift_Mime_Grammar
*/
private static $grammar = null;
/**
* Checks if an e-mail address matches the current grammars.
*
* @param string $email
*
* @return bool
*/
public static function email($email)
{
if (self::$grammar === null) {
self::$grammar = Swift_DependencyContainer::getInstance()
->lookup('mime.grammar');
}
return (bool) preg_match(
'/^'.self::$grammar->getDefinition('addr-spec').'$/D',
$email
);
}
}
<?php
Swift_DependencyContainer::getInstance()
->register('cache')
->asAliasOf('cache.array')
->register('tempdir')
->asValue('/tmp')
->register('cache.null')
->asSharedInstanceOf('Swift_KeyCache_NullKeyCache')
->register('cache.array')
->asSharedInstanceOf('Swift_KeyCache_ArrayKeyCache')
->withDependencies(array('cache.inputstream'))
->register('cache.disk')
->asSharedInstanceOf('Swift_KeyCache_DiskKeyCache')
->withDependencies(array('cache.inputstream', 'tempdir'))
->register('cache.inputstream')
->asNewInstanceOf('Swift_KeyCache_SimpleKeyCacheInputStream')
;
<?php
Swift_DependencyContainer::getInstance()
->register('message.message')
->asNewInstanceOf('Swift_Message')
->register('message.mimepart')
->asNewInstanceOf('Swift_MimePart')
;
<?php
require __DIR__.'/../mime_types.php';
Swift_DependencyContainer::getInstance()
->register('properties.charset')
->asValue('utf-8')
->register('mime.grammar')
->asSharedInstanceOf('Swift_Mime_Grammar')
->register('mime.message')
->asNewInstanceOf('Swift_Mime_SimpleMessage')
->withDependencies(array(
'mime.headerset',
'mime.qpcontentencoder',
'cache',
'mime.grammar',
'properties.charset',
))
->register('mime.part')
->asNewInstanceOf('Swift_Mime_MimePart')
->withDependencies(array(
'mime.headerset',
'mime.qpcontentencoder',
'cache',
'mime.grammar',
'properties.charset',
))
->register('mime.attachment')
->asNewInstanceOf('Swift_Mime_Attachment')
->withDependencies(array(
'mime.headerset',
'mime.base64contentencoder',
'cache',
'mime.grammar',
))
->addConstructorValue($swift_mime_types)
->register('mime.embeddedfile')
->asNewInstanceOf('Swift_Mime_EmbeddedFile')
->withDependencies(array(
'mime.headerset',
'mime.base64contentencoder',
'cache',
'mime.grammar',
))
->addConstructorValue($swift_mime_types)
->register('mime.headerfactory')
->asNewInstanceOf('Swift_Mime_SimpleHeaderFactory')
->withDependencies(array(
'mime.qpheaderencoder',
'mime.rfc2231encoder',
'mime.grammar',
'properties.charset',
))
->register('mime.headerset')
->asNewInstanceOf('Swift_Mime_SimpleHeaderSet')
->withDependencies(array('mime.headerfactory', 'properties.charset'))
->register('mime.qpheaderencoder')
->asNewInstanceOf('Swift_Mime_HeaderEncoder_QpHeaderEncoder')
->withDependencies(array('mime.charstream'))
->register('mime.base64headerencoder')
->asNewInstanceOf('Swift_Mime_HeaderEncoder_Base64HeaderEncoder')
->withDependencies(array('mime.charstream'))
->register('mime.charstream')
->asNewInstanceOf('Swift_CharacterStream_NgCharacterStream')
->withDependencies(array('mime.characterreaderfactory', 'properties.charset'))
->register('mime.bytecanonicalizer')
->asSharedInstanceOf('Swift_StreamFilters_ByteArrayReplacementFilter')
->addConstructorValue(array(array(0x0D, 0x0A), array(0x0D), array(0x0A)))
->addConstructorValue(array(array(0x0A), array(0x0A), array(0x0D, 0x0A)))
->register('mime.characterreaderfactory')
->asSharedInstanceOf('Swift_CharacterReaderFactory_SimpleCharacterReaderFactory')
->register('mime.safeqpcontentencoder')
->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
->register('mime.rawcontentencoder')
->asNewInstanceOf('Swift_Mime_ContentEncoder_RawContentEncoder')
->register('mime.nativeqpcontentencoder')
->withDependencies(array('properties.charset'))
->asNewInstanceOf('Swift_Mime_ContentEncoder_NativeQpContentEncoder')
->register('mime.qpcontentencoderproxy')
->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoderProxy')
->withDependencies(array('mime.safeqpcontentencoder', 'mime.nativeqpcontentencoder', 'properties.charset'))
->register('mime.7bitcontentencoder')
->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
->addConstructorValue('7bit')
->addConstructorValue(true)
->register('mime.8bitcontentencoder')
->asNewInstanceOf('Swift_Mime_ContentEncoder_PlainContentEncoder')
->addConstructorValue('8bit')
->addConstructorValue(true)
->register('mime.base64contentencoder')
->asSharedInstanceOf('Swift_Mime_ContentEncoder_Base64ContentEncoder')
->register('mime.rfc2231encoder')
->asNewInstanceOf('Swift_Encoder_Rfc2231Encoder')
->withDependencies(array('mime.charstream'))
// As of PHP 5.4.7, the quoted_printable_encode() function behaves correctly.
// see https://github.com/php/php-src/commit/18bb426587d62f93c54c40bf8535eb8416603629
->register('mime.qpcontentencoder')
->asAliasOf(PHP_VERSION_ID >= 50407 ? 'mime.qpcontentencoderproxy' : 'mime.safeqpcontentencoder')
;
unset($swift_mime_types);
<?php
Swift_DependencyContainer::getInstance()
->register('transport.smtp')
->asNewInstanceOf('Swift_Transport_EsmtpTransport')
->withDependencies(array(
'transport.buffer',
array('transport.authhandler'),
'transport.eventdispatcher',
))
->register('transport.sendmail')
->asNewInstanceOf('Swift_Transport_SendmailTransport')
->withDependencies(array(
'transport.buffer',
'transport.eventdispatcher',
))
->register('transport.mail')
->asNewInstanceOf('Swift_Transport_MailTransport')
->withDependencies(array('transport.mailinvoker', 'transport.eventdispatcher'))
->register('transport.loadbalanced')
->asNewInstanceOf('Swift_Transport_LoadBalancedTransport')
->register('transport.failover')
->asNewInstanceOf('Swift_Transport_FailoverTransport')
->register('transport.spool')
->asNewInstanceOf('Swift_Transport_SpoolTransport')
->withDependencies(array('transport.eventdispatcher'))
->register('transport.null')
->asNewInstanceOf('Swift_Transport_NullTransport')
->withDependencies(array('transport.eventdispatcher'))
->register('transport.mailinvoker')
->asSharedInstanceOf('Swift_Transport_SimpleMailInvoker')
->register('transport.buffer')
->asNewInstanceOf('Swift_Transport_StreamBuffer')
->withDependencies(array('transport.replacementfactory'))
->register('transport.authhandler')
->asNewInstanceOf('Swift_Transport_Esmtp_AuthHandler')
->withDependencies(array(
array(
'transport.crammd5auth',
'transport.loginauth',
'transport.plainauth',
'transport.ntlmauth',
'transport.xoauth2auth',
),
))
->register('transport.crammd5auth')
->asNewInstanceOf('Swift_Transport_Esmtp_Auth_CramMd5Authenticator')
->register('transport.loginauth')
->asNewInstanceOf('Swift_Transport_Esmtp_Auth_LoginAuthenticator')
->register('transport.plainauth')
->asNewInstanceOf('Swift_Transport_Esmtp_Auth_PlainAuthenticator')
->register('transport.xoauth2auth')
->asNewInstanceOf('Swift_Transport_Esmtp_Auth_XOAuth2Authenticator')
->register('transport.ntlmauth')
->asNewInstanceOf('Swift_Transport_Esmtp_Auth_NTLMAuthenticator')
->register('transport.eventdispatcher')
->asNewInstanceOf('Swift_Events_SimpleEventDispatcher')
->register('transport.replacementfactory')
->asSharedInstanceOf('Swift_StreamFilters_StringReplacementFilterFactory')
;
<?php
/****************************************************************************/
/* */
/* YOU MAY WISH TO MODIFY OR REMOVE THE FOLLOWING LINES WHICH SET DEFAULTS */
/* */
/****************************************************************************/
$preferences = Swift_Preferences::getInstance();
// Sets the default charset so that setCharset() is not needed elsewhere
$preferences->setCharset('utf-8');
// Without these lines the default caching mechanism is "array" but this uses a lot of memory.
// If possible, use a disk cache to enable attaching large attachments etc.
// You can override the default temporary directory by setting the TMPDIR environment variable.
if (@is_writable($tmpDir = sys_get_temp_dir())) {
$preferences->setTempDir($tmpDir)->setCacheType('disk');
}
// this should only be done when Swiftmailer won't use the native QP content encoder
// see mime_deps.php
if (PHP_VERSION_ID < 50407) {
$preferences->setQPDotEscape(false);
}
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Dependency injection initialization for Swift Mailer.
*/
if (defined('SWIFT_INIT_LOADED')) {
return;
}
define('SWIFT_INIT_LOADED', true);
// Load in dependency maps
require __DIR__.'/dependency_maps/cache_deps.php';
require __DIR__.'/dependency_maps/mime_deps.php';
require __DIR__.'/dependency_maps/message_deps.php';
require __DIR__.'/dependency_maps/transport_deps.php';
// Load in global library preferences
require __DIR__.'/preferences.php';
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Autoloader and dependency injection initialization for Swift Mailer.
*/
if (class_exists('Swift', false)) {
return;
}
// Load Swift utility class
require __DIR__.'/classes/Swift.php';
if (!function_exists('_swiftmailer_init')) {
function _swiftmailer_init()
{
require __DIR__.'/swift_init.php';
}
}
// Start the autoloader and lazy-load the init script to set up dependency injection
Swift::registerAutoload('_swiftmailer_init');
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Autoloader and dependency injection initialization for Swift Mailer.
*/
if (class_exists('Swift', false)) {
return;
}
// Load Swift utility class
require __DIR__.'/Swift.php';
if (!function_exists('_swiftmailer_init')) {
function _swiftmailer_init()
{
require __DIR__.'/swift_init.php';
}
}
// Start the autoloader and lazy-load the init script to set up dependency injection
Swift::registerAutoload('_swiftmailer_init');
#!/usr/bin/php
<?php
define('APACHE_MIME_TYPES_URL', 'http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types');
define('FREEDESKTOP_XML_URL', 'https://raw2.github.com/minad/mimemagic/master/script/freedesktop.org.xml');
function generateUpToDateMimeArray()
{
$preamble = "<?php\n\n";
$preamble .= "/*\n";
$preamble .= " * This file is part of SwiftMailer.\n";
$preamble .= " * (c) 2004-2009 Chris Corbyn\n *\n";
$preamble .= " * For the full copyright and license information, please view the LICENSE\n";
$preamble .= " * file that was distributed with this source code.\n *\n";
$preamble .= " * autogenerated using http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types\n";
$preamble .= " * and https://raw.github.com/minad/mimemagic/master/script/freedesktop.org.xml\n";
$preamble .= " */\n\n";
$preamble .= "/*\n";
$preamble .= " * List of MIME type automatically detected in Swift Mailer.\n";
$preamble .= " */\n\n";
$preamble .= "// You may add or take away what you like (lowercase required)\n\n";
// get current mime types files
$mime_types = @file_get_contents(APACHE_MIME_TYPES_URL);
$mime_xml = @file_get_contents(FREEDESKTOP_XML_URL);
// prepare valid mime types
$valid_mime_types = array();
// split mime type and extensions eg. "video/x-matroska mkv mk3d mks"
if (preg_match_all('/^#?([a-z0-9\-\+\/\.]+)[\t]+(.*)$/miu', $mime_types, $matches) !== false) {
// collection of predefined mimetypes (bugfix for wrong resolved or missing mime types)
$valid_mime_types_preset = array(
'php' => 'application/x-php',
'php3' => 'application/x-php',
'php4' => 'application/x-php',
'php5' => 'application/x-php',
'zip' => 'application/zip',
'gif' => 'image/gif',
'png' => 'image/png',
'css' => 'text/css',
'js' => 'text/javascript',
'txt' => 'text/plain',
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'avi' => 'video/avi',
'bmp' => 'image/bmp',
'bz2' => 'application/x-bz2',
'csv' => 'text/csv',
'dmg' => 'application/x-apple-diskimage',
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'eml' => 'message/rfc822',
'aps' => 'application/postscript',
'exe' => 'application/x-ms-dos-executable',
'flv' => 'video/x-flv',
'gz' => 'application/x-gzip',
'hqx' => 'application/stuffit',
'htm' => 'text/html',
'html' => 'text/html',
'jar' => 'application/x-java-archive',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'm3u' => 'audio/x-mpegurl',
'm4a' => 'audio/mp4',
'mdb' => 'application/x-msaccess',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mov' => 'video/quicktime',
'mp3' => 'audio/mpeg',
'mp4' => 'video/mp4',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'odg' => 'vnd.oasis.opendocument.graphics',
'odp' => 'vnd.oasis.opendocument.presentation',
'odt' => 'vnd.oasis.opendocument.text',
'ods' => 'vnd.oasis.opendocument.spreadsheet',
'ogg' => 'audio/ogg',
'pdf' => 'application/pdf',
'ppt' => 'application/vnd.ms-powerpoint',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'ps' => 'application/postscript',
'rar' => 'application/x-rar-compressed',
'rtf' => 'application/rtf',
'tar' => 'application/x-tar',
'sit' => 'application/x-stuffit',
'svg' => 'image/svg+xml',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'ttf' => 'application/x-font-truetype',
'vcf' => 'text/x-vcard',
'wav' => 'audio/wav',
'wma' => 'audio/x-ms-wma',
'wmv' => 'audio/x-ms-wmv',
'xls' => 'application/excel',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xml' => 'application/xml',
);
// wrap array for generating file
foreach ($valid_mime_types_preset as $extension => $mime_type) {
// generate array for mimetype to extension resolver (only first match)
$valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'";
}
// collect extensions
$valid_extensions = array();
// all extensions from second match
foreach ($matches[2] as $i => $extensions) {
// explode multiple extensions from string
$extensions = explode(' ', strtolower($extensions));
// force array for foreach
if (!is_array($extensions)) {
$extensions = array($extensions);
}
foreach ($extensions as $extension) {
// get mime type
$mime_type = $matches[1][$i];
// check if string length lower than 10
if (strlen($extension) < 10) {
// add extension
$valid_extensions[] = $extension;
if (!isset($valid_mime_types[$mime_type])) {
// generate array for mimetype to extension resolver (only first match)
$valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'";
}
}
}
}
}
$xml = simplexml_load_string($mime_xml);
foreach ($xml as $node) {
// check if there is no pattern
if (!isset($node->glob['pattern'])) {
continue;
}
// get all matching extensions from match
foreach ((array) $node->glob['pattern'] as $extension) {
// skip none glob extensions
if (strpos($extension, '.') === false) {
continue;
}
// remove get only last part
$extension = explode('.', strtolower($extension));
$extension = end($extension);
// maximum length in database column
if (strlen($extension) <= 9) {
$valid_extensions[] = $extension;
}
}
if (isset($node->glob['pattern'][0])) {
// mime type
$mime_type = strtolower((string) $node['type']);
// get first extension
$extension = strtolower(trim($node->glob['ddpattern'][0], '*.'));
// skip none glob extensions and check if string length between 1 and 10
if (strpos($extension, '.') !== false || strlen($extension) < 1 || strlen($extension) > 9) {
continue;
}
// check if string length lower than 10
if (!isset($valid_mime_types[$mime_type])) {
// generate array for mimetype to extension resolver (only first match)
$valid_mime_types[$extension] = "'{$extension}' => '{$mime_type}'";
}
}
}
// full list of valid extensions only
$valid_mime_types = array_unique($valid_mime_types);
ksort($valid_mime_types);
// combine mime types and extensions array
$output = "$preamble\$swift_mime_types = array(\n ".implode($valid_mime_types, ",\n ")."\n);";
// write mime_types.php config file
@file_put_contents('./mime_types.php', $output);
}
generateUpToDateMimeArray();
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
>
<php>
<ini name="intl.default_locale" value="en"/>
<ini name="intl.error_level" value="0"/>
<ini name="memory_limit" value="-1"/>
<ini name="error_reporting" value="-1" />
</php>
<testsuites>
<testsuite name="SwiftMailer unit tests">
<directory>tests/unit</directory>
</testsuite>
<testsuite name="SwiftMailer acceptance tests">
<directory>tests/acceptance</directory>
</testsuite>
<testsuite name="SwiftMailer bug">
<directory>tests/bug</directory>
</testsuite>
<testsuite name="SwiftMailer smoke tests">
<directory>tests/smoke</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
<listener class="Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>
<?php
/**
* A binary safe string comparison.
*
* @author Chris Corbyn
*/
class IdenticalBinaryConstraint extends \PHPUnit_Framework_Constraint
{
protected $value;
public function __construct($value)
{
$this->value = $value;
}
/**
* Evaluates the constraint for parameter $other. Returns TRUE if the
* constraint is met, FALSE otherwise.
*
* @param mixed $other Value or object to evaluate.
*
* @return bool
*/
public function matches($other)
{
$aHex = $this->asHexString($this->value);
$bHex = $this->asHexString($other);
return $aHex === $bHex;
}
/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString()
{
return 'indentical binary';
}
/**
* Get the given string of bytes as a stirng of Hexadecimal sequences.
*
* @param string $binary
*
* @return string
*/
private function asHexString($binary)
{
$hex = '';
$bytes = unpack('H*', $binary);
foreach ($bytes as &$byte) {
$byte = strtoupper($byte);
}
return implode('', $bytes);
}
}
<?php
class Swift_StreamCollector
{
public $content = '';
public function __invoke($arg)
{
$this->content .= $arg;
}
}
<?php
/**
* Base test for smoke tests.
*
* @author Rouven Weßling
*/
class SwiftMailerSmokeTestCase extends SwiftMailerTestCase
{
protected function setUp()
{
if (!defined('SWIFT_SMOKE_TRANSPORT_TYPE')) {
$this->markTestSkipped(
'Smoke tests are skipped if tests/smoke.conf.php is not edited'
);
}
}
protected function _getMailer()
{
switch (SWIFT_SMOKE_TRANSPORT_TYPE) {
case 'smtp':
$transport = Swift_DependencyContainer::getInstance()->lookup('transport.smtp')
->setHost(SWIFT_SMOKE_SMTP_HOST)
->setPort(SWIFT_SMOKE_SMTP_PORT)
->setUsername(SWIFT_SMOKE_SMTP_USER)
->setPassword(SWIFT_SMOKE_SMTP_PASS)
->setEncryption(SWIFT_SMOKE_SMTP_ENCRYPTION)
;
break;
case 'sendmail':
$transport = Swift_DependencyContainer::getInstance()->lookup('transport.sendmail')
->setCommand(SWIFT_SMOKE_SENDMAIL_COMMAND)
;
break;
case 'mail':
case 'nativemail':
$transport = Swift_DependencyContainer::getInstance()->lookup('transport.mail');
break;
default:
throw new Exception('Undefined transport ['.SWIFT_SMOKE_TRANSPORT_TYPE.']');
}
return new Swift_Mailer($transport);
}
}
<?php
/**
* A base test case with some custom expectations.
*
* @author Rouven Weßling
*/
class SwiftMailerTestCase extends \PHPUnit_Framework_TestCase
{
public static function regExp($pattern)
{
if (!is_string($pattern)) {
throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
}
return new PHPUnit_Framework_Constraint_PCREMatch($pattern);
}
public function assertIdenticalBinary($expected, $actual, $message = '')
{
$constraint = new IdenticalBinaryConstraint($expected);
self::assertThat($actual, $constraint, $message);
}
protected function tearDown()
{
\Mockery::close();
}
protected function getMockery($class)
{
return \Mockery::mock($class);
}
}
ISO-2022-JPは、インターネット上(特に電子メール)などで使われる日本の文字用の文字符号化方式。ISO/IEC 2022のエスケープシーケンスを利用して文字集合を切り替える7ビットのコードであることを特徴とする (アナウンス機能のエスケープシーケンスは省略される)。俗に「JISコード」と呼ばれることもある。
概要
日本語表記への利用が想定されている文字コードであり、日本語の利用されるネットワークにおいて、日本の規格を応用したものである。また文字集合としては、日本語で用いられる漢字、ひらがな、カタカナはもちろん、ラテン文字、ギリシア文字、キリル文字なども含んでおり、学術や産業の分野での利用も考慮たものとなっている。規格名に、ISOの日本語の言語コードであるjaではなく、国・地域名コードのJPが示されているゆえんである。
文字集合としてJIS X 0201のC0集合(制御文字)、JIS X 0201のラテン文字集合、ISO 646の国際基準版図形文字、JIS X 0208の1978年版(JIS C 6226-1978)と1983年および1990年版が利用できる。JIS X 0201の片仮名文字集合は利用できない。1986年以降、日本の電子メールで用いられてきたJUNETコードを、村井純・Mark Crispin・Erik van der Poelが1993年にRFC化したもの(RFC 1468)。後にJIS X 0208:1997の附属書2としてJISに規定された。MIMEにおける文字符号化方式の識別用の名前として IANA に登録されている。
なお、符号化の仕様についてはISO/IEC 2022#ISO-2022-JPも参照。
ISO-2022-JPと非標準的拡張使用
「JISコード」(または「ISO-2022-JP」)というコード名の規定下では、その仕様通りの使用が求められる。しかし、Windows OS上では、実際にはCP932コード (MicrosoftによるShift JISを拡張した亜種。ISO-2022-JP規定外文字が追加されている。)による独自拡張(の文字)を断りなく使うアプリケーションが多い。この例としてInternet ExplorerやOutlook Expressがある。また、EmEditor、秀丸エディタやThunderbirdのようなMicrosoft社以外のWindowsアプリケーションでも同様の場合がある。この場合、ISO-2022-JPの範囲外の文字を使ってしまうと、異なる製品間では未定義不明文字として認識されるか、もしくは文字化けを起こす原因となる。そのため、Windows用の電子メールクライアントであっても独自拡張の文字を使用すると警告を出したり、あえて使えないように制限しているものも存在する。さらにはISO-2022-JPの範囲内であってもCP932は非標準文字(FULLWIDTH TILDE等)を持つので文字化けの原因になり得る。
また、符号化方式名をISO-2022-JPとしているのに、文字集合としてはJIS X 0212 (いわゆる補助漢字) やJIS X 0201の片仮名文字集合 (いわゆる半角カナ) をも符号化している例があるが、ISO-2022-JPではこれらの文字を許容していない。これらの符号化は独自拡張の実装であり、中にはISO/IEC 2022の仕様に準拠すらしていないものもある[2]。従って受信側の電子メールクライアントがこれらの独自拡張に対応していない場合、その文字あるいはその文字を含む行、時にはテキスト全体が文字化けすることがある。
Op mat eraus hinnen beschte, rou zënne schaddreg ké. Ké sin Eisen Kaffi prächteg, den haut esou Fielse wa, Well zielen d'Welt am dir. Aus grousse rëschten d'Stroos do, as dat Kléder gewëss d'Kàchen. Schied gehéiert d'Vioule net hu, rou ke zënter Säiten d'Hierz. Ze eise Fletschen mat, gei as gréng d'Lëtzebuerger. Wäit räich no mat.
Säiten d'Liewen aus en. Un gëtt bléit lossen wee, da wéi alle weisen Kolrettchen. Et deser d'Pan d'Kirmes vun, en wuel Benn rëschten méi. En get drem ménger beschte, da wär Stad welle. Nun Dach d'Pied do, mä gét ruffen gehéiert. Ze onser ugedon fir, d'Liewen Plett'len ech no, si Räis wielen bereet wat. Iwer spilt fir jo.
An hin däischter Margréitchen, eng ke Frot brommt, vu den Räis néierens. Da hir Hunn Frot nozegon, rout Fläiß Himmel zum si, net gutt Kaffi Gesträich fu. Vill lait Gaart sou wa, Land Mamm Schuebersonndeg rei do. Gei geet Minutt en, gei d'Leit beschte Kolrettchen et, Mamm fergiess un hun.
Et gutt Heck kommen oft, Lann rëscht rei um, Hunn rëscht schéinste ke der. En lait zielen schnéiwäiss hir, fu rou botze éiweg Minutt, rem fest gudden schaddreg en. Noper bereet Margréitchen mat op, dem denkt d'Leit d'Vioule no, oft ké Himmel Hämmel. En denkt blénken Fréijor net, Gart Schiet d'Natur no wou. No hin Ierd Frot d'Kirmes. Hire aremt un rou, ké den éiweg wielen Milliounen.
Mir si Hunn Blénkeg. Ké get ston derfir d'Kàchen. Haut d'Pan fu ons, dé frou löschteg d'Meereische rei. Sou op wuel Léift. Stret schlon grousse gin hu. Mä denkt d'Leit hinnen net, ké gét haut fort rëscht.
Koum d'Pan hannendrun ass ké, ké den brét Kaffi geplot. Schéi Hären d'Pied fu gét, do d'Mier néierens bei. Rëm päift Hämmel am, wee Engel beschéngt mä. Brommt klinzecht der ke, wa rout jeitzt dén. Get Zalot d'Vioule däischter da, jo fir Bänk päift duerch, bei d'Beem schéinen Plett'len jo. Den haut Faarwen ze, eng en Biereg Kirmesdag, um sin alles Faarwen d'Vioule.
Eng Hunn Schied et, wat wa Frot fest gebotzt. Bei jo bleiwe ruffen Klarinett. Un Feld klinzecht gét, rifft Margréitchen rem ke. Mir dé Noper duurch gewëss, ston sech kille sin en. Gei Stret d'Wise um, Haus Gart wee as. Monn ménger an blo, wat da Gart gefällt Hämmelsbrot.
Brommt geplot och ze, dat wa Räis Well Kaffi. Do get spilt prächteg, as wär kille bleiwe gewalteg. Onser frësch Margréitchen rem ke, blo en huet ugedon. Onser Hemecht wär de, hu eraus d'Sonn dat, eise deser hannendrun da och.
As durch Himmel hun, no fest iw'rem schéinste mir, Hunn séngt Hierz ke zum. Séngt iw'rem d'Natur zum an. Ke wär gutt Grénge. Kënnt gudden prächteg mä rei. Dé dir Blénkeg Klarinett Kolrettchen, da fort muerges d'Kanner wou, main Feld ruffen vu wéi. Da gin esou Zalot gewalteg, gét vill Hemecht blénken dé.
Haut gréng nun et, nei vu Bass gréng d'Gaassen. Fest d'Beem uechter si gin. Oft vu sinn wellen kréien. Et ass lait Zalot schéinen.
\ No newline at end of file
Код одно гринспана руководишь на. Его вы знания движение. Ты две начать
одиночку, сказать основатель удовольствием но миф. Бы какие система тем.
Полностью использует три мы, человек клоунов те нас, бы давать творческую
эзотерическая шеф.
Мог не помнить никакого сэкономленного, две либо какие пишите бы. Должен
компанию кто те, этот заключалась проектировщик не ты. Глупые периоды ты
для. Вам который хороший он. Те любых кремния концентрируются мог,
собирать принадлежите без вы.
Джоэла меньше хорошего вы миф, за тем году разработки. Даже управляющим
руководители был не. Три коде выпускать заботиться ну. То его система
удовольствием безостановочно, или ты главной процессорах. Мы без джоэл
знания получат, статьи остальные мы ещё.
Них русском касается поскольку по, образование должником
систематизированный ну мои. Прийти кандидата университет но нас, для бы
должны никакого, биг многие причин интервьюирования за.
Тем до плиту почему. Вот учёт такие одного бы, об биг разным внешних
промежуток. Вас до какому возможностей безответственный, были погодите бы
его, по них глупые долгий количества.
रखति आवश्यकत प्रेरना मुख्यतह हिंदी किएलोग असक्षम कार्यलय करते विवरण किके मानसिक दिनांक पुर्व संसाध एवम् कुशलता अमितकुमार प्रोत्साहित जनित देखने उदेशीत विकसित बलवान ब्रौशर किएलोग विश्लेषण लोगो कैसे जागरुक प्रव्रुति प्रोत्साहित सदस्य आवश्यकत प्रसारन उपलब्धता अथवा हिंदी जनित दर्शाता यन्त्रालय बलवान अतित सहयोग शुरुआत सभीकुछ माहितीवानीज्य लिये खरिदे है।अभी एकत्रित सम्पर्क रिती मुश्किल प्राथमिक भेदनक्षमता विश्व उन्हे गटको द्वारा तकरीबन
विश्व द्वारा व्याख्या सके। आजपर वातावरण व्याख्यान पहोच। हमारी कीसे प्राथमिक विचारशिलता पुर्व करती कम्प्युटर भेदनक्षमता लिये बलवान और्४५० यायेका वार्तालाप सुचना भारत शुरुआत लाभान्वित पढाए संस्था वर्णित मार्गदर्शन चुनने
\ No newline at end of file
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDZeUdi1RKnm9cRYNn6E24xxrRTouh3Va8JOEHQ5SB018lvbjwH
2lW5mZ/I0kh/dHsTN0zcN0VE62WIbnLreMk/af/4Pg1i93+c9TmfXmoropsmdLos
w0tjq50jGbBqtHZNJYAokP/u3uUuRw8g0V/O4zlQ3GlO/PDH7xDQzekl9wIDAQAB
AoGAaoCBXD5a72hbb/BNb7HaUlgscZUjYWW93bcGTGYZef8/b+m9Tl83gjhgzvlk
db62k1eOtX3/11uskp78eqLhctv7yWc0mQQhgOogY2qCwHTCH8wja8kJkUAnKQhs
P9sa5iJvgckiuX3SdxgTMwib9d1VyGq6YywiORiZF9rxyhECQQD/xhiZSi7y0ciB
g4bassy0GVMS7EDRumMHc8wC23E1H2mj5yPE/QLqkW4ddmCv2BbJnYmyNvOaK9tk
T2W+mn3/AkEA2aqDGja9CaTlY4BCXfiT166n+xVl5+d+1DENQ4FK9O2jpSi1265J
tjEkXVxUOpV1ZEcUVOdK6RpvsK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YC9A
Sv4BAoGAXCIC1xxAJP15osUuQjcM8KdsL1qw+LiPB2+cJJ2VMAZGV7CR2K0aCsis
OwRaYM0jZKUpxzp1uwtfrfqbhdYsv+jIBkfwoShYZuo6MhbUrj0sffkhJC3WrT2z
xafCFLFv1idzGvvNxatlp1DNKrndG2NS3syVAox9MnL5OMsvGM8=
-----END RSA PRIVATE KEY-----
#!/bin/sh
openssl genrsa -out CA.key 2048
openssl req -x509 -new -nodes -key CA.key -days 1460 -subj '/CN=Swiftmailer CA/O=Swiftmailer/L=Paris/C=FR' -out CA.crt
openssl x509 -in CA.crt -clrtrust -out CA.crt
openssl genrsa -out sign.key 2048
openssl req -new -key sign.key -subj '/CN=Swiftmailer-User/O=Swiftmailer/L=Paris/C=FR' -out sign.csr
openssl x509 -req -in sign.csr -CA CA.crt -CAkey CA.key -out sign.crt -days 1460 -addtrust emailProtection
openssl x509 -in sign.crt -clrtrust -out sign.crt
rm sign.csr
openssl genrsa -out intermediate.key 2048
openssl req -new -key intermediate.key -subj '/CN=Swiftmailer Intermediate/O=Swiftmailer/L=Paris/C=FR' -out intermediate.csr
openssl x509 -req -in intermediate.csr -CA CA.crt -CAkey CA.key -set_serial 01 -out intermediate.crt -days 1460
openssl x509 -in intermediate.crt -clrtrust -out intermediate.crt
rm intermediate.csr
openssl genrsa -out sign2.key 2048
openssl req -new -key sign2.key -subj '/CN=Swiftmailer-User2/O=Swiftmailer/L=Paris/C=FR' -out sign2.csr
openssl x509 -req -in sign2.csr -CA intermediate.crt -CAkey intermediate.key -set_serial 01 -out sign2.crt -days 1460 -addtrust emailProtection
openssl x509 -in sign2.crt -clrtrust -out sign2.crt
rm sign2.csr
openssl genrsa -out encrypt.key 2048
openssl req -new -key encrypt.key -subj '/CN=Swiftmailer-User/O=Swiftmailer/L=Paris/C=FR' -out encrypt.csr
openssl x509 -req -in encrypt.csr -CA CA.crt -CAkey CA.key -CAcreateserial -out encrypt.crt -days 1460 -addtrust emailProtection
openssl x509 -in encrypt.crt -clrtrust -out encrypt.crt
rm encrypt.csr
openssl genrsa -out encrypt2.key 2048
openssl req -new -key encrypt2.key -subj '/CN=Swiftmailer-User2/O=Swiftmailer/L=Paris/C=FR' -out encrypt2.csr
openssl x509 -req -in encrypt2.csr -CA CA.crt -CAkey CA.key -CAcreateserial -out encrypt2.crt -days 1460 -addtrust emailProtection
openssl x509 -in encrypt2.crt -clrtrust -out encrypt2.crt
rm encrypt2.csr
-----BEGIN CERTIFICATE-----
MIIDFjCCAf4CCQDULaNM+Q+g3TANBgkqhkiG9w0BAQUFADBMMRcwFQYDVQQDDA5T
d2lmdG1haWxlciBDQTEUMBIGA1UECgwLU3dpZnRtYWlsZXIxDjAMBgNVBAcMBVBh
cmlzMQswCQYDVQQGEwJGUjAeFw0xMzExMjcwODM5MTFaFw0xNzExMjYwODM5MTFa
ME4xGTAXBgNVBAMMEFN3aWZ0bWFpbGVyLVVzZXIxFDASBgNVBAoMC1N3aWZ0bWFp
bGVyMQ4wDAYDVQQHDAVQYXJpczELMAkGA1UEBhMCRlIwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQCcNO+fVZBT2znmVwXXZ08n3G5WA1kyvqh9z4RBBZOD
V46Gc1X9MMXr9+wzZBFkAckKaa6KsTkeUr4pC8XUBpQnakxH/kW9CaDPdOE+7wNo
FkPfc6pjWWgpAVxdkrtk7pb4/aGQ++HUkqVu0cMpIcj/7ht7H+3QLZHybn+oMr2+
FDnn8vPmHxVioinSrxKTlUITuLWS9ZZUTrDa0dG8UAv55A/Tba4T4McCPDpJSA4m
9jrW321NGQUntQoItOJxagaueSvh6PveGV826gTXoU5X+YJ3I2OZUEQ2l6yByAzf
nT+QlxPj5ikotFwL72HsenYtetynOO/k43FblAF/V/l7AgMBAAEwDQYJKoZIhvcN
AQEFBQADggEBAJ048Sdb9Sw5OJM5L00OtGHgcT1B/phqdzSjkM/s64cg3Q20VN+F
fZIIkOnxgyYWcpOWXcdNw2tm5OWhWPGsBcYgM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rXXHJSUmaOfbweX/mzFup0YR1LxUjcv85
cxvwc41Y2iI5MwUXyX97/GYKeoobzWZy3XflNWtg04rcInVaPsb/OOFDDqI+MkzT
B4PcCurOmjzcxHMVE34CYvl3YVwWrPb5JO1rYG9T2gKUJnLU6qG4Bw==
-----END RSA PRIVATE KEY-----
<?php
/*
Swift Mailer V4 accpetance test configuration.
YOU ONLY NEED TO EDIT THIS FILE IF YOU WISH TO RUN THE ACCEPTANCE TESTS.
The acceptance tests are run by default when "All Tests" are run with the
testing suite, however, without configuration options here only the unit tests
will be run and the acceptance tests will be skipped.
You can fill out only the parts you know and leave the other bits.
*/
/*
Defines: The name and port of a SMTP server you can connect to.
Recommended: smtp.gmail.com:25
*/
define('SWIFT_SMTP_HOST', 'localhost:4456');
/*
Defines: An SMTP server and port which uses TLS encryption.
Recommended: smtp.gmail.com:465
*/
define('SWIFT_TLS_HOST', 'smtp.gmail.com:465');
/*
Defines: An SMTP server and port which uses SSL encryption.
Recommended: smtp.gmail.com:465
*/
define('SWIFT_SSL_HOST', 'smtp.gmail.com:465');
/*
Defines: The path to a sendmail binary (one which can run in -bs mode).
Recommended: /usr/sbin/sendmail
*/
define('SWIFT_SENDMAIL_PATH', '/usr/sbin/sendmail -bs');
<?php
require_once 'swift_required.php';
require_once __DIR__.'/Mime/AttachmentAcceptanceTest.php';
class Swift_AttachmentAcceptanceTest extends Swift_Mime_AttachmentAcceptanceTest
{
protected function _createAttachment()
{
return Swift_Attachment::newInstance();
}
}
<?php
class Swift_ByteStream_FileByteStreamAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_testFile;
protected function setUp()
{
$this->_testFile = sys_get_temp_dir().'/swift-test-file'.__CLASS__;
file_put_contents($this->_testFile, 'abcdefghijklm');
}
protected function tearDown()
{
unlink($this->_testFile);
}
public function testFileDataCanBeRead()
{
$file = $this->_createFileStream($this->_testFile);
$str = '';
while (false !== $bytes = $file->read(8192)) {
$str .= $bytes;
}
$this->assertEquals('abcdefghijklm', $str);
}
public function testFileDataCanBeReadSequentially()
{
$file = $this->_createFileStream($this->_testFile);
$this->assertEquals('abcde', $file->read(5));
$this->assertEquals('fghijklm', $file->read(8));
$this->assertFalse($file->read(1));
}
public function testFilenameIsReturned()
{
$file = $this->_createFileStream($this->_testFile);
$this->assertEquals($this->_testFile, $file->getPath());
}
public function testFileCanBeWrittenTo()
{
$file = $this->_createFileStream($this->_testFile, true);
$file->write('foobar');
$this->assertEquals('foobar', $file->read(8192));
}
public function testReadingFromThenWritingToFile()
{
$file = $this->_createFileStream($this->_testFile, true);
$file->write('foobar');
$this->assertEquals('foobar', $file->read(8192));
$file->write('zipbutton');
$this->assertEquals('zipbutton', $file->read(8192));
}
public function testWritingToFileWithCanonicalization()
{
$file = $this->_createFileStream($this->_testFile, true);
$file->addFilter($this->_createFilter(array("\r\n", "\r"), "\n"), 'allToLF');
$file->write("foo\r\nbar\r");
$file->write("\nzip\r\ntest\r");
$file->flushBuffers();
$this->assertEquals("foo\nbar\nzip\ntest\n", file_get_contents($this->_testFile));
}
public function testWritingWithFulleMessageLengthOfAMultipleOf8192()
{
$file = $this->_createFileStream($this->_testFile, true);
$file->addFilter($this->_createFilter(array("\r\n", "\r"), "\n"), 'allToLF');
$file->write('');
$file->flushBuffers();
$this->assertEquals('', file_get_contents($this->_testFile));
}
public function testBindingOtherStreamsMirrorsWriteOperations()
{
$file = $this->_createFileStream($this->_testFile, true);
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$is1->expects($this->at(0))
->method('write')
->with('x');
$is1->expects($this->at(1))
->method('write')
->with('y');
$is2->expects($this->at(0))
->method('write')
->with('x');
$is2->expects($this->at(1))
->method('write')
->with('y');
$file->bind($is1);
$file->bind($is2);
$file->write('x');
$file->write('y');
}
public function testBindingOtherStreamsMirrorsFlushOperations()
{
$file = $this->_createFileStream(
$this->_testFile, true
);
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$is1->expects($this->once())
->method('flushBuffers');
$is2->expects($this->once())
->method('flushBuffers');
$file->bind($is1);
$file->bind($is2);
$file->flushBuffers();
}
public function testUnbindingStreamPreventsFurtherWrites()
{
$file = $this->_createFileStream($this->_testFile, true);
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$is1->expects($this->at(0))
->method('write')
->with('x');
$is1->expects($this->at(1))
->method('write')
->with('y');
$is2->expects($this->once())
->method('write')
->with('x');
$file->bind($is1);
$file->bind($is2);
$file->write('x');
$file->unbind($is2);
$file->write('y');
}
private function _createFilter($search, $replace)
{
return new Swift_StreamFilters_StringReplacementFilter($search, $replace);
}
private function _createMockInputStream()
{
return $this->getMockBuilder('Swift_InputByteStream')->getMock();
}
private function _createFileStream($file, $writable = false)
{
return new Swift_ByteStream_FileByteStream($file, $writable);
}
}
<?php
class Swift_CharacterReaderFactory_SimpleCharacterReaderFactoryAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_factory;
private $_prefix = 'Swift_CharacterReader_';
protected function setUp()
{
$this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
}
public function testCreatingUtf8Reader()
{
foreach (array('utf8', 'utf-8', 'UTF-8', 'UTF8') as $utf8) {
$reader = $this->_factory->getReaderFor($utf8);
$this->assertInstanceof($this->_prefix.'Utf8Reader', $reader);
}
}
public function testCreatingIso8859XReaders()
{
$charsets = array();
foreach (range(1, 16) as $number) {
foreach (array('iso', 'iec') as $body) {
$charsets[] = $body.'-8859-'.$number;
$charsets[] = $body.'8859-'.$number;
$charsets[] = strtoupper($body).'-8859-'.$number;
$charsets[] = strtoupper($body).'8859-'.$number;
}
}
foreach ($charsets as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingWindows125XReaders()
{
$charsets = array();
foreach (range(0, 8) as $number) {
$charsets[] = 'windows-125'.$number;
$charsets[] = 'windows125'.$number;
$charsets[] = 'WINDOWS-125'.$number;
$charsets[] = 'WINDOWS125'.$number;
}
foreach ($charsets as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingCodePageReaders()
{
$charsets = array();
foreach (range(0, 8) as $number) {
$charsets[] = 'cp-125'.$number;
$charsets[] = 'cp125'.$number;
$charsets[] = 'CP-125'.$number;
$charsets[] = 'CP125'.$number;
}
foreach (array(437, 737, 850, 855, 857, 858, 860,
861, 863, 865, 866, 869, ) as $number) {
$charsets[] = 'cp-'.$number;
$charsets[] = 'cp'.$number;
$charsets[] = 'CP-'.$number;
$charsets[] = 'CP'.$number;
}
foreach ($charsets as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingAnsiReader()
{
foreach (array('ansi', 'ANSI') as $ansi) {
$reader = $this->_factory->getReaderFor($ansi);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingMacintoshReader()
{
foreach (array('macintosh', 'MACINTOSH') as $mac) {
$reader = $this->_factory->getReaderFor($mac);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingKOIReaders()
{
$charsets = array();
foreach (array('7', '8-r', '8-u', '8u', '8r') as $end) {
$charsets[] = 'koi-'.$end;
$charsets[] = 'koi'.$end;
$charsets[] = 'KOI-'.$end;
$charsets[] = 'KOI'.$end;
}
foreach ($charsets as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingIsciiReaders()
{
foreach (array('iscii', 'ISCII', 'viscii', 'VISCII') as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingMIKReader()
{
foreach (array('mik', 'MIK') as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingCorkReader()
{
foreach (array('cork', 'CORK', 't1', 'T1') as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(1, $reader->getInitialByteSize());
}
}
public function testCreatingUcs2Reader()
{
foreach (array('ucs-2', 'UCS-2', 'ucs2', 'UCS2') as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(2, $reader->getInitialByteSize());
}
}
public function testCreatingUtf16Reader()
{
foreach (array('utf-16', 'UTF-16', 'utf16', 'UTF16') as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(2, $reader->getInitialByteSize());
}
}
public function testCreatingUcs4Reader()
{
foreach (array('ucs-4', 'UCS-4', 'ucs4', 'UCS4') as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(4, $reader->getInitialByteSize());
}
}
public function testCreatingUtf32Reader()
{
foreach (array('utf-32', 'UTF-32', 'utf32', 'UTF32') as $charset) {
$reader = $this->_factory->getReaderFor($charset);
$this->assertInstanceof($this->_prefix.'GenericFixedWidthReader', $reader);
$this->assertEquals(4, $reader->getInitialByteSize());
}
}
}
<?php
require_once 'swift_required.php';
//This is more of a "cross your fingers and hope it works" test!
class Swift_DependencyContainerAcceptanceTest extends \PHPUnit_Framework_TestCase
{
public function testNoLookupsFail()
{
$di = Swift_DependencyContainer::getInstance();
foreach ($di->listItems() as $itemName) {
try {
// to be removed in 6.0
if ('transport.mail' === $itemName) {
continue;
}
$di->lookup($itemName);
} catch (Swift_DependencyException $e) {
$this->fail($e->getMessage());
}
}
}
}
<?php
require_once 'swift_required.php';
require_once __DIR__.'/Mime/EmbeddedFileAcceptanceTest.php';
class Swift_EmbeddedFileAcceptanceTest extends Swift_Mime_EmbeddedFileAcceptanceTest
{
protected function _createEmbeddedFile()
{
return Swift_EmbeddedFile::newInstance();
}
}
<?php
class Swift_Encoder_Base64EncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_samplesDir;
private $_encoder;
protected function setUp()
{
$this->_samplesDir = realpath(__DIR__.'/../../../_samples/charsets');
$this->_encoder = new Swift_Encoder_Base64Encoder();
}
public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$encodedText = $this->_encoder->encodeString($text);
$this->assertEquals(
base64_decode($encodedText), $text,
'%s: Encoded string should decode back to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
}
<?php
class Swift_Encoder_QpEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_samplesDir;
private $_factory;
protected function setUp()
{
$this->_samplesDir = realpath(__DIR__.'/../../../_samples/charsets');
$this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
}
public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$encoding = $encodingDir;
$charStream = new Swift_CharacterStream_ArrayCharacterStream(
$this->_factory, $encoding);
$encoder = new Swift_Encoder_QpEncoder($charStream);
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$encodedText = $encoder->encodeString($text);
foreach (explode("\r\n", $encodedText) as $line) {
$this->assertLessThanOrEqual(76, strlen($line));
}
$this->assertEquals(
quoted_printable_decode($encodedText), $text,
'%s: Encoded string should decode back to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
}
<?php
class Swift_Encoder_Rfc2231EncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_samplesDir;
private $_factory;
protected function setUp()
{
$this->_samplesDir = realpath(__DIR__.'/../../../_samples/charsets');
$this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
}
public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$encoding = $encodingDir;
$charStream = new Swift_CharacterStream_ArrayCharacterStream(
$this->_factory, $encoding);
$encoder = new Swift_Encoder_Rfc2231Encoder($charStream);
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$encodedText = $encoder->encodeString($text);
$this->assertEquals(
urldecode(implode('', explode("\r\n", $encodedText))), $text,
'%s: Encoded string should decode back to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
}
<?php
require_once 'swift_required.php';
class Swift_EncodingAcceptanceTest extends \PHPUnit_Framework_TestCase
{
public function testGet7BitEncodingReturns7BitEncoder()
{
$encoder = Swift_Encoding::get7BitEncoding();
$this->assertEquals('7bit', $encoder->getName());
}
public function testGet8BitEncodingReturns8BitEncoder()
{
$encoder = Swift_Encoding::get8BitEncoding();
$this->assertEquals('8bit', $encoder->getName());
}
public function testGetQpEncodingReturnsQpEncoder()
{
$encoder = Swift_Encoding::getQpEncoding();
$this->assertEquals('quoted-printable', $encoder->getName());
}
public function testGetBase64EncodingReturnsBase64Encoder()
{
$encoder = Swift_Encoding::getBase64Encoding();
$this->assertEquals('base64', $encoder->getName());
}
}
<?php
class Swift_KeyCache_ArrayKeyCacheAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_cache;
private $_key1 = 'key1';
private $_key2 = 'key2';
protected function setUp()
{
$this->_cache = new Swift_KeyCache_ArrayKeyCache(
new Swift_KeyCache_SimpleKeyCacheInputStream()
);
}
public function testStringDataCanBeSetAndFetched()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo'));
}
public function testStringDataCanBeOverwritten()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('whatever', $this->_cache->getString($this->_key1, 'foo'));
}
public function testStringDataCanBeAppended()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND
);
$this->assertEquals('testing', $this->_cache->getString($this->_key1, 'foo'));
}
public function testHasKeyReturnValue()
{
$this->assertFalse($this->_cache->hasKey($this->_key1, 'foo'));
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->assertTrue($this->_cache->hasKey($this->_key1, 'foo'));
}
public function testNsKeyIsWellPartitioned()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo'));
$this->assertEquals('ing', $this->_cache->getString($this->_key2, 'foo'));
}
public function testItemKeyIsWellPartitioned()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo'));
$this->assertEquals('ing', $this->_cache->getString($this->_key1, 'bar'));
}
public function testByteStreamCanBeImported()
{
$os = new Swift_ByteStream_ArrayByteStream();
$os->write('abcdef');
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('abcdef', $this->_cache->getString($this->_key1, 'foo'));
}
public function testByteStreamCanBeAppended()
{
$os1 = new Swift_ByteStream_ArrayByteStream();
$os1->write('abcdef');
$os2 = new Swift_ByteStream_ArrayByteStream();
$os2->write('xyzuvw');
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND
);
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND
);
$this->assertEquals('abcdefxyzuvw', $this->_cache->getString($this->_key1, 'foo'));
}
public function testByteStreamAndStringCanBeAppended()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND
);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write('abcdef');
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND
);
$this->assertEquals('testabcdef', $this->_cache->getString($this->_key1, 'foo'));
}
public function testDataCanBeExportedToByteStream()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$is = new Swift_ByteStream_ArrayByteStream();
$this->_cache->exportToByteStream($this->_key1, 'foo', $is);
$string = '';
while (false !== $bytes = $is->read(8192)) {
$string .= $bytes;
}
$this->assertEquals('test', $string);
}
public function testKeyCanBeCleared()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->assertTrue($this->_cache->hasKey($this->_key1, 'foo'));
$this->_cache->clearKey($this->_key1, 'foo');
$this->assertFalse($this->_cache->hasKey($this->_key1, 'foo'));
}
public function testNsKeyCanBeCleared()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE
);
$this->assertTrue($this->_cache->hasKey($this->_key1, 'foo'));
$this->assertTrue($this->_cache->hasKey($this->_key1, 'bar'));
$this->_cache->clearAll($this->_key1);
$this->assertFalse($this->_cache->hasKey($this->_key1, 'foo'));
$this->assertFalse($this->_cache->hasKey($this->_key1, 'bar'));
}
public function testKeyCacheInputStream()
{
$is = $this->_cache->getInputByteStream($this->_key1, 'foo');
$is->write('abc');
$is->write('xyz');
$this->assertEquals('abcxyz', $this->_cache->getString($this->_key1, 'foo'));
}
}
<?php
class Swift_KeyCache_DiskKeyCacheAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_cache;
private $_key1;
private $_key2;
protected function setUp()
{
$this->_key1 = uniqid(microtime(true), true);
$this->_key2 = uniqid(microtime(true), true);
$this->_cache = new Swift_KeyCache_DiskKeyCache(new Swift_KeyCache_SimpleKeyCacheInputStream(), sys_get_temp_dir());
}
public function testStringDataCanBeSetAndFetched()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo'));
}
public function testStringDataCanBeOverwritten()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'foo', 'whatever', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('whatever', $this->_cache->getString($this->_key1, 'foo'));
}
public function testStringDataCanBeAppended()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'foo', 'ing', Swift_KeyCache::MODE_APPEND
);
$this->assertEquals('testing', $this->_cache->getString($this->_key1, 'foo'));
}
public function testHasKeyReturnValue()
{
$this->assertFalse($this->_cache->hasKey($this->_key1, 'foo'));
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->assertTrue($this->_cache->hasKey($this->_key1, 'foo'));
}
public function testNsKeyIsWellPartitioned()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key2, 'foo', 'ing', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo'));
$this->assertEquals('ing', $this->_cache->getString($this->_key2, 'foo'));
}
public function testItemKeyIsWellPartitioned()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'bar', 'ing', Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('test', $this->_cache->getString($this->_key1, 'foo'));
$this->assertEquals('ing', $this->_cache->getString($this->_key1, 'bar'));
}
public function testByteStreamCanBeImported()
{
$os = new Swift_ByteStream_ArrayByteStream();
$os->write('abcdef');
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os, Swift_KeyCache::MODE_WRITE
);
$this->assertEquals('abcdef', $this->_cache->getString($this->_key1, 'foo'));
}
public function testByteStreamCanBeAppended()
{
$os1 = new Swift_ByteStream_ArrayByteStream();
$os1->write('abcdef');
$os2 = new Swift_ByteStream_ArrayByteStream();
$os2->write('xyzuvw');
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os1, Swift_KeyCache::MODE_APPEND
);
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os2, Swift_KeyCache::MODE_APPEND
);
$this->assertEquals('abcdefxyzuvw', $this->_cache->getString($this->_key1, 'foo'));
}
public function testByteStreamAndStringCanBeAppended()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_APPEND
);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write('abcdef');
$this->_cache->importFromByteStream(
$this->_key1, 'foo', $os, Swift_KeyCache::MODE_APPEND
);
$this->assertEquals('testabcdef', $this->_cache->getString($this->_key1, 'foo'));
}
public function testDataCanBeExportedToByteStream()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$is = new Swift_ByteStream_ArrayByteStream();
$this->_cache->exportToByteStream($this->_key1, 'foo', $is);
$string = '';
while (false !== $bytes = $is->read(8192)) {
$string .= $bytes;
}
$this->assertEquals('test', $string);
}
public function testKeyCanBeCleared()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->assertTrue($this->_cache->hasKey($this->_key1, 'foo'));
$this->_cache->clearKey($this->_key1, 'foo');
$this->assertFalse($this->_cache->hasKey($this->_key1, 'foo'));
}
public function testNsKeyCanBeCleared()
{
$this->_cache->setString(
$this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE
);
$this->_cache->setString(
$this->_key1, 'bar', 'xyz', Swift_KeyCache::MODE_WRITE
);
$this->assertTrue($this->_cache->hasKey($this->_key1, 'foo'));
$this->assertTrue($this->_cache->hasKey($this->_key1, 'bar'));
$this->_cache->clearAll($this->_key1);
$this->assertFalse($this->_cache->hasKey($this->_key1, 'foo'));
$this->assertFalse($this->_cache->hasKey($this->_key1, 'bar'));
}
public function testKeyCacheInputStream()
{
$is = $this->_cache->getInputByteStream($this->_key1, 'foo');
$is->write('abc');
$is->write('xyz');
$this->assertEquals('abcxyz', $this->_cache->getString($this->_key1, 'foo'));
}
}
<?php
require_once 'swift_required.php';
require_once __DIR__.'/Mime/SimpleMessageAcceptanceTest.php';
class Swift_MessageAcceptanceTest extends Swift_Mime_SimpleMessageAcceptanceTest
{
public function testAddPartWrapper()
{
$message = $this->_createMessage();
$message->setSubject('just a test subject');
$message->setFrom(array(
'chris.corbyn@swiftmailer.org' => 'Chris Corbyn', ));
$id = $message->getId();
$date = $message->getDate();
$boundary = $message->getBoundary();
$message->addPart('foo', 'text/plain', 'iso-8859-1');
$message->addPart('test <b>foo</b>', 'text/html', 'iso-8859-1');
$this->assertEquals(
'Message-ID: <'.$id.'>'."\r\n".
'Date: '.date('r', $date)."\r\n".
'Subject: just a test subject'."\r\n".
'From: Chris Corbyn <chris.corbyn@swiftmailer.org>'."\r\n".
'MIME-Version: 1.0'."\r\n".
'Content-Type: multipart/alternative;'."\r\n".
' boundary="'.$boundary.'"'."\r\n".
"\r\n\r\n".
'--'.$boundary."\r\n".
'Content-Type: text/plain; charset=iso-8859-1'."\r\n".
'Content-Transfer-Encoding: quoted-printable'."\r\n".
"\r\n".
'foo'.
"\r\n\r\n".
'--'.$boundary."\r\n".
'Content-Type: text/html; charset=iso-8859-1'."\r\n".
'Content-Transfer-Encoding: quoted-printable'."\r\n".
"\r\n".
'test <b>foo</b>'.
"\r\n\r\n".
'--'.$boundary.'--'."\r\n",
$message->toString()
);
}
protected function _createMessage()
{
Swift_DependencyContainer::getInstance()
->register('properties.charset')->asValue(null);
return Swift_Message::newInstance();
}
}
<?php
class Swift_Mime_AttachmentAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_contentEncoder;
private $_cache;
private $_grammar;
private $_headers;
protected function setUp()
{
$this->_cache = new Swift_KeyCache_ArrayKeyCache(
new Swift_KeyCache_SimpleKeyCacheInputStream()
);
$factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
$this->_contentEncoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
$headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder(
new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')
);
$paramEncoder = new Swift_Encoder_Rfc2231Encoder(
new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')
);
$this->_grammar = new Swift_Mime_Grammar();
$this->_headers = new Swift_Mime_SimpleHeaderSet(
new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar)
);
}
public function testDispositionIsSetInHeader()
{
$attachment = $this->_createAttachment();
$attachment->setContentType('application/pdf');
$attachment->setDisposition('inline');
$this->assertEquals(
'Content-Type: application/pdf'."\r\n".
'Content-Transfer-Encoding: base64'."\r\n".
'Content-Disposition: inline'."\r\n",
$attachment->toString()
);
}
public function testDispositionIsAttachmentByDefault()
{
$attachment = $this->_createAttachment();
$attachment->setContentType('application/pdf');
$this->assertEquals(
'Content-Type: application/pdf'."\r\n".
'Content-Transfer-Encoding: base64'."\r\n".
'Content-Disposition: attachment'."\r\n",
$attachment->toString()
);
}
public function testFilenameIsSetInHeader()
{
$attachment = $this->_createAttachment();
$attachment->setContentType('application/pdf');
$attachment->setFilename('foo.pdf');
$this->assertEquals(
'Content-Type: application/pdf; name=foo.pdf'."\r\n".
'Content-Transfer-Encoding: base64'."\r\n".
'Content-Disposition: attachment; filename=foo.pdf'."\r\n",
$attachment->toString()
);
}
public function testSizeIsSetInHeader()
{
$attachment = $this->_createAttachment();
$attachment->setContentType('application/pdf');
$attachment->setSize(12340);
$this->assertEquals(
'Content-Type: application/pdf'."\r\n".
'Content-Transfer-Encoding: base64'."\r\n".
'Content-Disposition: attachment; size=12340'."\r\n",
$attachment->toString()
);
}
public function testMultipleParametersInHeader()
{
$attachment = $this->_createAttachment();
$attachment->setContentType('application/pdf');
$attachment->setFilename('foo.pdf');
$attachment->setSize(12340);
$this->assertEquals(
'Content-Type: application/pdf; name=foo.pdf'."\r\n".
'Content-Transfer-Encoding: base64'."\r\n".
'Content-Disposition: attachment; filename=foo.pdf; size=12340'."\r\n",
$attachment->toString()
);
}
public function testEndToEnd()
{
$attachment = $this->_createAttachment();
$attachment->setContentType('application/pdf');
$attachment->setFilename('foo.pdf');
$attachment->setSize(12340);
$attachment->setBody('abcd');
$this->assertEquals(
'Content-Type: application/pdf; name=foo.pdf'."\r\n".
'Content-Transfer-Encoding: base64'."\r\n".
'Content-Disposition: attachment; filename=foo.pdf; size=12340'."\r\n".
"\r\n".
base64_encode('abcd'),
$attachment->toString()
);
}
protected function _createAttachment()
{
$entity = new Swift_Mime_Attachment(
$this->_headers,
$this->_contentEncoder,
$this->_cache,
$this->_grammar
);
return $entity;
}
}
<?php
class Swift_Mime_ContentEncoder_Base64ContentEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_samplesDir;
private $_encoder;
protected function setUp()
{
$this->_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets');
$this->_encoder = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
}
public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write($text);
$is = new Swift_ByteStream_ArrayByteStream();
$this->_encoder->encodeByteStream($os, $is);
$encoded = '';
while (false !== $bytes = $is->read(8192)) {
$encoded .= $bytes;
}
$this->assertEquals(
base64_decode($encoded), $text,
'%s: Encoded string should decode back to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
}
<?php
class Swift_Mime_ContentEncoder_NativeQpContentEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
protected $_samplesDir;
/**
* @var Swift_Mime_ContentEncoder_NativeQpContentEncoder
*/
protected $_encoder;
protected function setUp()
{
$this->_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets');
$this->_encoder = new Swift_Mime_ContentEncoder_NativeQpContentEncoder();
}
public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write($text);
$is = new Swift_ByteStream_ArrayByteStream();
$this->_encoder->encodeByteStream($os, $is);
$encoded = '';
while (false !== $bytes = $is->read(8192)) {
$encoded .= $bytes;
}
$this->assertEquals(
quoted_printable_decode($encoded),
// CR and LF are converted to CRLF
preg_replace('~\r(?!\n)|(?<!\r)\n~', "\r\n", $text),
'%s: Encoded string should decode back to original string for sample '.$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
public function testEncodingAndDecodingSamplesFromDiConfiguredInstance()
{
$encoder = $this->_createEncoderFromContainer();
$this->assertSame('=C3=A4=C3=B6=C3=BC=C3=9F', $encoder->encodeString('äöüß'));
}
/**
* @expectedException \RuntimeException
*/
public function testCharsetChangeNotImplemented()
{
$this->_encoder->charsetChanged('utf-8');
$this->_encoder->charsetChanged('charset');
$this->_encoder->encodeString('foo');
}
public function testGetName()
{
$this->assertSame('quoted-printable', $this->_encoder->getName());
}
private function _createEncoderFromContainer()
{
return Swift_DependencyContainer::getInstance()
->lookup('mime.nativeqpcontentencoder')
;
}
}
<?php
class Swift_Mime_ContentEncoder_PlainContentEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_samplesDir;
private $_encoder;
protected function setUp()
{
$this->_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets');
$this->_encoder = new Swift_Mime_ContentEncoder_PlainContentEncoder('8bit');
}
public function testEncodingAndDecodingSamplesString()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$encodedText = $this->_encoder->encodeString($text);
$this->assertEquals(
$encodedText, $text,
'%s: Encoded string should be identical to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
public function testEncodingAndDecodingSamplesByteStream()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write($text);
$is = new Swift_ByteStream_ArrayByteStream();
$this->_encoder->encodeByteStream($os, $is);
$encoded = '';
while (false !== $bytes = $is->read(8192)) {
$encoded .= $bytes;
}
$this->assertEquals(
$encoded, $text,
'%s: Encoded string should be identical to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
}
<?php
class Swift_Mime_ContentEncoder_QpContentEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_samplesDir;
private $_factory;
protected function setUp()
{
$this->_samplesDir = realpath(__DIR__.'/../../../../_samples/charsets');
$this->_factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
}
protected function tearDown()
{
Swift_Preferences::getInstance()->setQPDotEscape(false);
}
public function testEncodingAndDecodingSamples()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$encoding = $encodingDir;
$charStream = new Swift_CharacterStream_NgCharacterStream(
$this->_factory, $encoding);
$encoder = new Swift_Mime_ContentEncoder_QpContentEncoder($charStream);
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write($text);
$is = new Swift_ByteStream_ArrayByteStream();
$encoder->encodeByteStream($os, $is);
$encoded = '';
while (false !== $bytes = $is->read(8192)) {
$encoded .= $bytes;
}
$this->assertEquals(
quoted_printable_decode($encoded), $text,
'%s: Encoded string should decode back to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
public function testEncodingAndDecodingSamplesFromDiConfiguredInstance()
{
$sampleFp = opendir($this->_samplesDir);
while (false !== $encodingDir = readdir($sampleFp)) {
if (substr($encodingDir, 0, 1) == '.') {
continue;
}
$encoding = $encodingDir;
$encoder = $this->_createEncoderFromContainer();
$sampleDir = $this->_samplesDir.'/'.$encodingDir;
if (is_dir($sampleDir)) {
$fileFp = opendir($sampleDir);
while (false !== $sampleFile = readdir($fileFp)) {
if (substr($sampleFile, 0, 1) == '.') {
continue;
}
$text = file_get_contents($sampleDir.'/'.$sampleFile);
$os = new Swift_ByteStream_ArrayByteStream();
$os->write($text);
$is = new Swift_ByteStream_ArrayByteStream();
$encoder->encodeByteStream($os, $is);
$encoded = '';
while (false !== $bytes = $is->read(8192)) {
$encoded .= $bytes;
}
$this->assertEquals(
str_replace("\r\n", "\n", quoted_printable_decode($encoded)), str_replace("\r\n", "\n", $text),
'%s: Encoded string should decode back to original string for sample '.
$sampleDir.'/'.$sampleFile
);
}
closedir($fileFp);
}
}
closedir($sampleFp);
}
public function testEncodingLFTextWithDiConfiguredInstance()
{
$encoder = $this->_createEncoderFromContainer();
$this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\nb\nc"));
}
public function testEncodingCRTextWithDiConfiguredInstance()
{
$encoder = $this->_createEncoderFromContainer();
$this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\rb\rc"));
}
public function testEncodingLFCRTextWithDiConfiguredInstance()
{
$encoder = $this->_createEncoderFromContainer();
$this->assertEquals("a\r\n\r\nb\r\n\r\nc", $encoder->encodeString("a\n\rb\n\rc"));
}
public function testEncodingCRLFTextWithDiConfiguredInstance()
{
$encoder = $this->_createEncoderFromContainer();
$this->assertEquals("a\r\nb\r\nc", $encoder->encodeString("a\r\nb\r\nc"));
}
public function testEncodingDotStuffingWithDiConfiguredInstance()
{
// Enable DotEscaping
Swift_Preferences::getInstance()->setQPDotEscape(true);
$encoder = $this->_createEncoderFromContainer();
$this->assertEquals("a=2E\r\n=2E\r\n=2Eb\r\nc", $encoder->encodeString("a.\r\n.\r\n.b\r\nc"));
// Return to default
Swift_Preferences::getInstance()->setQPDotEscape(false);
$encoder = $this->_createEncoderFromContainer();
$this->assertEquals("a.\r\n.\r\n.b\r\nc", $encoder->encodeString("a.\r\n.\r\n.b\r\nc"));
}
public function testDotStuffingEncodingAndDecodingSamplesFromDiConfiguredInstance()
{
// Enable DotEscaping
Swift_Preferences::getInstance()->setQPDotEscape(true);
$this->testEncodingAndDecodingSamplesFromDiConfiguredInstance();
}
private function _createEncoderFromContainer()
{
return Swift_DependencyContainer::getInstance()
->lookup('mime.qpcontentencoder')
;
}
}
<?php
class Swift_Mime_HeaderEncoder_Base64HeaderEncoderAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_encoder;
protected function setUp()
{
$this->_encoder = new Swift_Mime_HeaderEncoder_Base64HeaderEncoder();
}
public function testEncodingJIS()
{
if (function_exists('mb_convert_encoding')) {
// base64_encode and split cannot handle long JIS text to fold
$subject = '長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い長い件名';
$encodedWrapperLength = strlen('=?iso-2022-jp?'.$this->_encoder->getName().'??=');
$old = mb_internal_encoding();
mb_internal_encoding('utf-8');
$newstring = mb_encode_mimeheader($subject, 'iso-2022-jp', 'B', "\r\n");
mb_internal_encoding($old);
$encoded = $this->_encoder->encodeString($subject, 0, 75 - $encodedWrapperLength, 'iso-2022-jp');
$this->assertEquals(
$encoded, $newstring,
'Encoded string should decode back to original string for sample '
);
}
}
}
<?php
class Swift_Mime_MimePartAcceptanceTest extends \PHPUnit_Framework_TestCase
{
private $_contentEncoder;
private $_cache;
private $_grammar;
private $_headers;
protected function setUp()
{
$this->_cache = new Swift_KeyCache_ArrayKeyCache(
new Swift_KeyCache_SimpleKeyCacheInputStream()
);
$factory = new Swift_CharacterReaderFactory_SimpleCharacterReaderFactory();
$this->_contentEncoder = new Swift_Mime_ContentEncoder_QpContentEncoder(
new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8'),
new Swift_StreamFilters_ByteArrayReplacementFilter(
array(array(0x0D, 0x0A), array(0x0D), array(0x0A)),
array(array(0x0A), array(0x0A), array(0x0D, 0x0A))
)
);
$headerEncoder = new Swift_Mime_HeaderEncoder_QpHeaderEncoder(
new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')
);
$paramEncoder = new Swift_Encoder_Rfc2231Encoder(
new Swift_CharacterStream_ArrayCharacterStream($factory, 'utf-8')
);
$this->_grammar = new Swift_Mime_Grammar();
$this->_headers = new Swift_Mime_SimpleHeaderSet(
new Swift_Mime_SimpleHeaderFactory($headerEncoder, $paramEncoder, $this->_grammar)
);
}
public function testCharsetIsSetInHeader()
{
$part = $this->_createMimePart();
$part->setContentType('text/plain');
$part->setCharset('utf-8');
$part->setBody('foobar');
$this->assertEquals(
'Content-Type: text/plain; charset=utf-8'."\r\n".
'Content-Transfer-Encoding: quoted-printable'."\r\n".
"\r\n".
'foobar',
$part->toString()
);
}
public function testFormatIsSetInHeaders()
{
$part = $this->_createMimePart();
$part->setContentType('text/plain');
$part->setFormat('flowed');
$part->setBody('> foobar');
$this->assertEquals(
'Content-Type: text/plain; format=flowed'."\r\n".
'Content-Transfer-Encoding: quoted-printable'."\r\n".
"\r\n".
'> foobar',
$part->toString()
);
}
public function testDelSpIsSetInHeaders()
{
$part = $this->_createMimePart();
$part->setContentType('text/plain');
$part->setDelSp(true);
$part->setBody('foobar');
$this->assertEquals(
'Content-Type: text/plain; delsp=yes'."\r\n".
'Content-Transfer-Encoding: quoted-printable'."\r\n".
"\r\n".
'foobar',
$part->toString()
);
}
public function testAll3ParamsInHeaders()
{
$part = $this->_createMimePart();
$part->setContentType('text/plain');
$part->setCharset('utf-8');
$part->setFormat('fixed');
$part->setDelSp(true);
$part->setBody('foobar');
$this->assertEquals(
'Content-Type: text/plain; charset=utf-8; format=fixed; delsp=yes'."\r\n".
'Content-Transfer-Encoding: quoted-printable'."\r\n".
"\r\n".
'foobar',
$part->toString()
);
}
public function testBodyIsCanonicalized()
{
$part = $this->_createMimePart();
$part->setContentType('text/plain');
$part->setCharset('utf-8');
$part->setBody("foobar\r\rtest\ning\r");
$this->assertEquals(
'Content-Type: text/plain; charset=utf-8'."\r\n".
'Content-Transfer-Encoding: quoted-printable'."\r\n".
"\r\n".
"foobar\r\n".
"\r\n".
"test\r\n".
"ing\r\n",
$part->toString()
);
}
protected function _createMimePart()
{
$entity = new Swift_Mime_MimePart(
$this->_headers,
$this->_contentEncoder,
$this->_cache,
$this->_grammar
);
return $entity;
}
}
<?php
require_once 'swift_required.php';
require_once __DIR__.'/Mime/MimePartAcceptanceTest.php';
class Swift_MimePartAcceptanceTest extends Swift_Mime_MimePartAcceptanceTest
{
protected function _createMimePart()
{
Swift_DependencyContainer::getInstance()
->register('properties.charset')->asValue(null);
return Swift_MimePart::newInstance();
}
}
<?php
abstract class Swift_Transport_StreamBuffer_AbstractStreamBufferAcceptanceTest extends \PHPUnit_Framework_TestCase
{
protected $_buffer;
abstract protected function _initializeBuffer();
protected function setUp()
{
if (true == getenv('TRAVIS')) {
$this->markTestSkipped(
'Will fail on travis-ci if not skipped due to travis blocking '.
'socket mailing tcp connections.'
);
}
$this->_buffer = new Swift_Transport_StreamBuffer(
$this->getMockBuilder('Swift_ReplacementFilterFactory')->getMock()
);
}
public function testReadLine()
{
$this->_initializeBuffer();
$line = $this->_buffer->readLine(0);
$this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line);
$seq = $this->_buffer->write("QUIT\r\n");
$this->assertTrue((bool) $seq);
$line = $this->_buffer->readLine($seq);
$this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line);
$this->_buffer->terminate();
}
public function testWrite()
{
$this->_initializeBuffer();
$line = $this->_buffer->readLine(0);
$this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line);
$seq = $this->_buffer->write("HELO foo\r\n");
$this->assertTrue((bool) $seq);
$line = $this->_buffer->readLine($seq);
$this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line);
$seq = $this->_buffer->write("QUIT\r\n");
$this->assertTrue((bool) $seq);
$line = $this->_buffer->readLine($seq);
$this->assertRegExp('/^[0-9]{3}.*?\r\n$/D', $line);
$this->_buffer->terminate();
}
public function testBindingOtherStreamsMirrorsWriteOperations()
{
$this->_initializeBuffer();
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$is1->expects($this->at(0))
->method('write')
->with('x');
$is1->expects($this->at(1))
->method('write')
->with('y');
$is2->expects($this->at(0))
->method('write')
->with('x');
$is2->expects($this->at(1))
->method('write')
->with('y');
$this->_buffer->bind($is1);
$this->_buffer->bind($is2);
$this->_buffer->write('x');
$this->_buffer->write('y');
}
public function testBindingOtherStreamsMirrorsFlushOperations()
{
$this->_initializeBuffer();
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$is1->expects($this->once())
->method('flushBuffers');
$is2->expects($this->once())
->method('flushBuffers');
$this->_buffer->bind($is1);
$this->_buffer->bind($is2);
$this->_buffer->flushBuffers();
}
public function testUnbindingStreamPreventsFurtherWrites()
{
$this->_initializeBuffer();
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$is1->expects($this->at(0))
->method('write')
->with('x');
$is1->expects($this->at(1))
->method('write')
->with('y');
$is2->expects($this->once())
->method('write')
->with('x');
$this->_buffer->bind($is1);
$this->_buffer->bind($is2);
$this->_buffer->write('x');
$this->_buffer->unbind($is2);
$this->_buffer->write('y');
}
private function _createMockInputStream()
{
return $this->getMockBuilder('Swift_InputByteStream')->getMock();
}
}
<?php
require_once __DIR__.'/AbstractStreamBufferAcceptanceTest.php';
class Swift_Transport_StreamBuffer_BasicSocketAcceptanceTest extends Swift_Transport_StreamBuffer_AbstractStreamBufferAcceptanceTest
{
protected function setUp()
{
if (!defined('SWIFT_SMTP_HOST')) {
$this->markTestSkipped(
'Cannot run test without an SMTP host to connect to (define '.
'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)'
);
}
parent::setUp();
}
protected function _initializeBuffer()
{
$parts = explode(':', SWIFT_SMTP_HOST);
$host = $parts[0];
$port = isset($parts[1]) ? $parts[1] : 25;
$this->_buffer->initialize(array(
'type' => Swift_Transport_IoBuffer::TYPE_SOCKET,
'host' => $host,
'port' => $port,
'protocol' => 'tcp',
'blocking' => 1,
'timeout' => 15,
));
}
}
<?php
require_once __DIR__.'/AbstractStreamBufferAcceptanceTest.php';
class Swift_Transport_StreamBuffer_ProcessAcceptanceTest extends Swift_Transport_StreamBuffer_AbstractStreamBufferAcceptanceTest
{
protected function setUp()
{
if (!defined('SWIFT_SENDMAIL_PATH')) {
$this->markTestSkipped(
'Cannot run test without a path to sendmail (define '.
'SWIFT_SENDMAIL_PATH in tests/acceptance.conf.php if you wish to run this test)'
);
}
parent::setUp();
}
protected function _initializeBuffer()
{
$this->_buffer->initialize(array(
'type' => Swift_Transport_IoBuffer::TYPE_PROCESS,
'command' => SWIFT_SENDMAIL_PATH.' -bs',
));
}
}
<?php
class Swift_Transport_StreamBuffer_SocketTimeoutTest extends \PHPUnit_Framework_TestCase
{
protected $_buffer;
protected $_randomHighPort;
protected $_server;
protected function setUp()
{
if (!defined('SWIFT_SMTP_HOST')) {
$this->markTestSkipped(
'Cannot run test without an SMTP host to connect to (define '.
'SWIFT_SMTP_HOST in tests/acceptance.conf.php if you wish to run this test)'
);
}
$serverStarted = false;
for ($i = 0; $i < 5; ++$i) {
$this->_randomHighPort = rand(50000, 65000);
$this->_server = stream_socket_server('tcp://127.0.0.1:'.$this->_randomHighPort);
if ($this->_server) {
$serverStarted = true;
}
}
$this->_buffer = new Swift_Transport_StreamBuffer(
$this->getMockBuilder('Swift_ReplacementFilterFactory')->getMock()
);
}
protected function _initializeBuffer()
{
$host = '127.0.0.1';
$port = $this->_randomHighPort;
$this->_buffer->initialize(array(
'type' => Swift_Transport_IoBuffer::TYPE_SOCKET,
'host' => $host,
'port' => $port,
'protocol' => 'tcp',
'blocking' => 1,
'timeout' => 1,
));
}
public function testTimeoutException()
{
$this->_initializeBuffer();
$e = null;
try {
$line = $this->_buffer->readLine(0);
} catch (Exception $e) {
}
$this->assertInstanceof('Swift_IoException', $e, 'IO Exception Not Thrown On Connection Timeout');
$this->assertRegExp('/Connection to .* Timed Out/', $e->getMessage());
}
protected function tearDown()
{
if ($this->_server) {
stream_socket_shutdown($this->_server, STREAM_SHUT_RDWR);
}
}
}
<?php
require_once __DIR__.'/AbstractStreamBufferAcceptanceTest.php';
class Swift_Transport_StreamBuffer_SslSocketAcceptanceTest extends Swift_Transport_StreamBuffer_AbstractStreamBufferAcceptanceTest
{
protected function setUp()
{
$streams = stream_get_transports();
if (!in_array('ssl', $streams)) {
$this->markTestSkipped(
'SSL is not configured for your system. It is not possible to run this test'
);
}
if (!defined('SWIFT_SSL_HOST')) {
$this->markTestSkipped(
'Cannot run test without an SSL enabled SMTP host to connect to (define '.
'SWIFT_SSL_HOST in tests/acceptance.conf.php if you wish to run this test)'
);
}
parent::setUp();
}
protected function _initializeBuffer()
{
$parts = explode(':', SWIFT_SSL_HOST);
$host = $parts[0];
$port = isset($parts[1]) ? $parts[1] : 25;
$this->_buffer->initialize(array(
'type' => Swift_Transport_IoBuffer::TYPE_SOCKET,
'host' => $host,
'port' => $port,
'protocol' => 'ssl',
'blocking' => 1,
'timeout' => 15,
));
}
}
<?php
require_once __DIR__.'/AbstractStreamBufferAcceptanceTest.php';
class Swift_Transport_StreamBuffer_TlsSocketAcceptanceTest extends Swift_Transport_StreamBuffer_AbstractStreamBufferAcceptanceTest
{
protected function setUp()
{
$streams = stream_get_transports();
if (!in_array('tls', $streams)) {
$this->markTestSkipped(
'TLS is not configured for your system. It is not possible to run this test'
);
}
if (!defined('SWIFT_TLS_HOST')) {
$this->markTestSkipped(
'Cannot run test without a TLS enabled SMTP host to connect to (define '.
'SWIFT_TLS_HOST in tests/acceptance.conf.php if you wish to run this test)'
);
}
parent::setUp();
}
protected function _initializeBuffer()
{
$parts = explode(':', SWIFT_TLS_HOST);
$host = $parts[0];
$port = isset($parts[1]) ? $parts[1] : 25;
$this->_buffer->initialize(array(
'type' => Swift_Transport_IoBuffer::TYPE_SOCKET,
'host' => $host,
'port' => $port,
'protocol' => 'tls',
'blocking' => 1,
'timeout' => 15,
));
}
}
<?php
require_once dirname(__DIR__).'/vendor/autoload.php';
// Disable garbage collector to prevent segfaults
gc_disable();
set_include_path(get_include_path().PATH_SEPARATOR.dirname(__DIR__).'/lib');
Mockery::getConfiguration()->allowMockingNonExistentMethods(true);
if (is_file(__DIR__.'/acceptance.conf.php')) {
require_once __DIR__.'/acceptance.conf.php';
}
if (is_file(__DIR__.'/smoke.conf.php')) {
require_once __DIR__.'/smoke.conf.php';
}
require_once __DIR__.'/StreamCollector.php';
require_once __DIR__.'/IdenticalBinaryConstraint.php';
require_once __DIR__.'/SwiftMailerTestCase.php';
require_once __DIR__.'/SwiftMailerSmokeTestCase.php';
<?php
class Swift_Bug111Test extends \PHPUnit_Framework_TestCase
{
public function testUnstructuredHeaderSlashesShouldNotBeEscaped()
{
$complicated_header = array(
'to' => array(
'email1@example.com',
'email2@example.com',
'email3@example.com',
'email4@example.com',
'email5@example.com',
),
'sub' => array(
'-name-' => array(
'email1',
'"email2"',
'email3\\',
'email4',
'email5',
),
'-url-' => array(
'http://google.com',
'http://yahoo.com',
'http://hotmail.com',
'http://aol.com',
'http://facebook.com',
),
),
);
$json = json_encode($complicated_header);
$message = new Swift_Message();
$headers = $message->getHeaders();
$headers->addTextHeader('X-SMTPAPI', $json);
$header = $headers->get('X-SMTPAPI');
$this->assertEquals('Swift_Mime_Headers_UnstructuredHeader', get_class($header));
$this->assertEquals($json, $header->getFieldBody());
}
}
<?php
class Swift_ByteStream_ArrayByteStreamTest extends \PHPUnit_Framework_TestCase
{
public function testReadingSingleBytesFromBaseInput()
{
$input = array('a', 'b', 'c');
$bs = $this->_createArrayStream($input);
$output = array();
while (false !== $bytes = $bs->read(1)) {
$output[] = $bytes;
}
$this->assertEquals($input, $output,
'%s: Bytes read from stream should be the same as bytes in constructor'
);
}
public function testReadingMultipleBytesFromBaseInput()
{
$input = array('a', 'b', 'c', 'd');
$bs = $this->_createArrayStream($input);
$output = array();
while (false !== $bytes = $bs->read(2)) {
$output[] = $bytes;
}
$this->assertEquals(array('ab', 'cd'), $output,
'%s: Bytes read from stream should be in pairs'
);
}
public function testReadingOddOffsetOnLastByte()
{
$input = array('a', 'b', 'c', 'd', 'e');
$bs = $this->_createArrayStream($input);
$output = array();
while (false !== $bytes = $bs->read(2)) {
$output[] = $bytes;
}
$this->assertEquals(array('ab', 'cd', 'e'), $output,
'%s: Bytes read from stream should be in pairs except final read'
);
}
public function testSettingPointerPartway()
{
$input = array('a', 'b', 'c');
$bs = $this->_createArrayStream($input);
$bs->setReadPointer(1);
$this->assertEquals('b', $bs->read(1),
'%s: Byte should be second byte since pointer as at offset 1'
);
}
public function testResettingPointerAfterExhaustion()
{
$input = array('a', 'b', 'c');
$bs = $this->_createArrayStream($input);
while (false !== $bs->read(1));
$bs->setReadPointer(0);
$this->assertEquals('a', $bs->read(1),
'%s: Byte should be first byte since pointer as at offset 0'
);
}
public function testPointerNeverSetsBelowZero()
{
$input = array('a', 'b', 'c');
$bs = $this->_createArrayStream($input);
$bs->setReadPointer(-1);
$this->assertEquals('a', $bs->read(1),
'%s: Byte should be first byte since pointer should be at offset 0'
);
}
public function testPointerNeverSetsAboveStackSize()
{
$input = array('a', 'b', 'c');
$bs = $this->_createArrayStream($input);
$bs->setReadPointer(3);
$this->assertFalse($bs->read(1),
'%s: Stream should be at end and thus return false'
);
}
public function testBytesCanBeWrittenToStream()
{
$input = array('a', 'b', 'c');
$bs = $this->_createArrayStream($input);
$bs->write('de');
$output = array();
while (false !== $bytes = $bs->read(1)) {
$output[] = $bytes;
}
$this->assertEquals(array('a', 'b', 'c', 'd', 'e'), $output,
'%s: Bytes read from stream should be from initial stack + written'
);
}
public function testContentsCanBeFlushed()
{
$input = array('a', 'b', 'c');
$bs = $this->_createArrayStream($input);
$bs->flushBuffers();
$this->assertFalse($bs->read(1),
'%s: Contents have been flushed so read() should return false'
);
}
public function testConstructorCanTakeStringArgument()
{
$bs = $this->_createArrayStream('abc');
$output = array();
while (false !== $bytes = $bs->read(1)) {
$output[] = $bytes;
}
$this->assertEquals(array('a', 'b', 'c'), $output,
'%s: Bytes read from stream should be the same as bytes in constructor'
);
}
public function testBindingOtherStreamsMirrorsWriteOperations()
{
$bs = $this->_createArrayStream('');
$is1 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
$is2 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
$is1->expects($this->at(0))
->method('write')
->with('x');
$is1->expects($this->at(1))
->method('write')
->with('y');
$is2->expects($this->at(0))
->method('write')
->with('x');
$is2->expects($this->at(1))
->method('write')
->with('y');
$bs->bind($is1);
$bs->bind($is2);
$bs->write('x');
$bs->write('y');
}
public function testBindingOtherStreamsMirrorsFlushOperations()
{
$bs = $this->_createArrayStream('');
$is1 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
$is2 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
$is1->expects($this->once())
->method('flushBuffers');
$is2->expects($this->once())
->method('flushBuffers');
$bs->bind($is1);
$bs->bind($is2);
$bs->flushBuffers();
}
public function testUnbindingStreamPreventsFurtherWrites()
{
$bs = $this->_createArrayStream('');
$is1 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
$is2 = $this->getMockBuilder('Swift_InputByteStream')->getMock();
$is1->expects($this->at(0))
->method('write')
->with('x');
$is1->expects($this->at(1))
->method('write')
->with('y');
$is2->expects($this->once())
->method('write')
->with('x');
$bs->bind($is1);
$bs->bind($is2);
$bs->write('x');
$bs->unbind($is2);
$bs->write('y');
}
private function _createArrayStream($input)
{
return new Swift_ByteStream_ArrayByteStream($input);
}
}
<?php
class Swift_CharacterReader_GenericFixedWidthReaderTest extends \PHPUnit_Framework_TestCase
{
public function testInitialByteSizeMatchesWidth()
{
$reader = new Swift_CharacterReader_GenericFixedWidthReader(1);
$this->assertSame(1, $reader->getInitialByteSize());
$reader = new Swift_CharacterReader_GenericFixedWidthReader(4);
$this->assertSame(4, $reader->getInitialByteSize());
}
public function testValidationValueIsBasedOnOctetCount()
{
$reader = new Swift_CharacterReader_GenericFixedWidthReader(4);
$this->assertSame(
1, $reader->validateByteSequence(array(0x01, 0x02, 0x03), 3)
); //3 octets
$this->assertSame(
2, $reader->validateByteSequence(array(0x01, 0x0A), 2)
); //2 octets
$this->assertSame(
3, $reader->validateByteSequence(array(0xFE), 1)
); //1 octet
$this->assertSame(
0, $reader->validateByteSequence(array(0xFE, 0x03, 0x67, 0x9A), 4)
); //All 4 octets
}
public function testValidationFailsIfTooManyOctets()
{
$reader = new Swift_CharacterReader_GenericFixedWidthReader(6);
$this->assertSame(-1, $reader->validateByteSequence(
array(0xFE, 0x03, 0x67, 0x9A, 0x10, 0x09, 0x85), 7
)); //7 octets
}
}
<?php
class Swift_CharacterReader_UsAsciiReaderTest extends \PHPUnit_Framework_TestCase
{
/*
for ($c = '', $size = 1; false !== $bytes = $os->read($size); ) {
$c .= $bytes;
$size = $v->validateCharacter($c);
if (-1 == $size) {
throw new Exception( ... invalid char .. );
} elseif (0 == $size) {
return $c; //next character in $os
}
}
*/
private $_reader;
protected function setUp()
{
$this->_reader = new Swift_CharacterReader_UsAsciiReader();
}
public function testAllValidAsciiCharactersReturnZero()
{
for ($ordinal = 0x00; $ordinal <= 0x7F; ++$ordinal) {
$this->assertSame(
0, $this->_reader->validateByteSequence(array($ordinal), 1)
);
}
}
public function testMultipleBytesAreInvalid()
{
for ($ordinal = 0x00; $ordinal <= 0x7F; $ordinal += 2) {
$this->assertSame(
-1, $this->_reader->validateByteSequence(array($ordinal, $ordinal + 1), 2)
);
}
}
public function testBytesAboveAsciiRangeAreInvalid()
{
for ($ordinal = 0x80; $ordinal <= 0xFF; ++$ordinal) {
$this->assertSame(
-1, $this->_reader->validateByteSequence(array($ordinal), 1)
);
}
}
}
<?php
class Swift_CharacterReader_Utf8ReaderTest extends \PHPUnit_Framework_TestCase
{
private $_reader;
protected function setUp()
{
$this->_reader = new Swift_CharacterReader_Utf8Reader();
}
public function testLeading7BitOctetCausesReturnZero()
{
for ($ordinal = 0x00; $ordinal <= 0x7F; ++$ordinal) {
$this->assertSame(
0, $this->_reader->validateByteSequence(array($ordinal), 1)
);
}
}
public function testLeadingByteOf2OctetCharCausesReturn1()
{
for ($octet = 0xC0; $octet <= 0xDF; ++$octet) {
$this->assertSame(
1, $this->_reader->validateByteSequence(array($octet), 1)
);
}
}
public function testLeadingByteOf3OctetCharCausesReturn2()
{
for ($octet = 0xE0; $octet <= 0xEF; ++$octet) {
$this->assertSame(
2, $this->_reader->validateByteSequence(array($octet), 1)
);
}
}
public function testLeadingByteOf4OctetCharCausesReturn3()
{
for ($octet = 0xF0; $octet <= 0xF7; ++$octet) {
$this->assertSame(
3, $this->_reader->validateByteSequence(array($octet), 1)
);
}
}
public function testLeadingByteOf5OctetCharCausesReturn4()
{
for ($octet = 0xF8; $octet <= 0xFB; ++$octet) {
$this->assertSame(
4, $this->_reader->validateByteSequence(array($octet), 1)
);
}
}
public function testLeadingByteOf6OctetCharCausesReturn5()
{
for ($octet = 0xFC; $octet <= 0xFD; ++$octet) {
$this->assertSame(
5, $this->_reader->validateByteSequence(array($octet), 1)
);
}
}
}
<?php
class One
{
public $arg1;
public $arg2;
public function __construct($arg1 = null, $arg2 = null)
{
$this->arg1 = $arg1;
$this->arg2 = $arg2;
}
}
class Swift_DependencyContainerTest extends \PHPUnit_Framework_TestCase
{
private $_container;
protected function setUp()
{
$this->_container = new Swift_DependencyContainer();
}
public function testRegisterAndLookupValue()
{
$this->_container->register('foo')->asValue('bar');
$this->assertEquals('bar', $this->_container->lookup('foo'));
}
public function testHasReturnsTrueForRegisteredValue()
{
$this->_container->register('foo')->asValue('bar');
$this->assertTrue($this->_container->has('foo'));
}
public function testHasReturnsFalseForUnregisteredValue()
{
$this->assertFalse($this->_container->has('foo'));
}
public function testRegisterAndLookupNewInstance()
{
$this->_container->register('one')->asNewInstanceOf('One');
$this->assertInstanceof('One', $this->_container->lookup('one'));
}
public function testHasReturnsTrueForRegisteredInstance()
{
$this->_container->register('one')->asNewInstanceOf('One');
$this->assertTrue($this->_container->has('one'));
}
public function testNewInstanceIsAlwaysNew()
{
$this->_container->register('one')->asNewInstanceOf('One');
$a = $this->_container->lookup('one');
$b = $this->_container->lookup('one');
$this->assertEquals($a, $b);
}
public function testRegisterAndLookupSharedInstance()
{
$this->_container->register('one')->asSharedInstanceOf('One');
$this->assertInstanceof('One', $this->_container->lookup('one'));
}
public function testHasReturnsTrueForSharedInstance()
{
$this->_container->register('one')->asSharedInstanceOf('One');
$this->assertTrue($this->_container->has('one'));
}
public function testMultipleSharedInstancesAreSameInstance()
{
$this->_container->register('one')->asSharedInstanceOf('One');
$a = $this->_container->lookup('one');
$b = $this->_container->lookup('one');
$this->assertEquals($a, $b);
}
public function testNewInstanceWithDependencies()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('one')->asNewInstanceOf('One')
->withDependencies(array('foo'));
$obj = $this->_container->lookup('one');
$this->assertSame('FOO', $obj->arg1);
}
public function testNewInstanceWithMultipleDependencies()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('bar')->asValue(42);
$this->_container->register('one')->asNewInstanceOf('One')
->withDependencies(array('foo', 'bar'));
$obj = $this->_container->lookup('one');
$this->assertSame('FOO', $obj->arg1);
$this->assertSame(42, $obj->arg2);
}
public function testNewInstanceWithInjectedObjects()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('one')->asNewInstanceOf('One');
$this->_container->register('two')->asNewInstanceOf('One')
->withDependencies(array('one', 'foo'));
$obj = $this->_container->lookup('two');
$this->assertEquals($this->_container->lookup('one'), $obj->arg1);
$this->assertSame('FOO', $obj->arg2);
}
public function testNewInstanceWithAddConstructorValue()
{
$this->_container->register('one')->asNewInstanceOf('One')
->addConstructorValue('x')
->addConstructorValue(99);
$obj = $this->_container->lookup('one');
$this->assertSame('x', $obj->arg1);
$this->assertSame(99, $obj->arg2);
}
public function testNewInstanceWithAddConstructorLookup()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('bar')->asValue(42);
$this->_container->register('one')->asNewInstanceOf('One')
->addConstructorLookup('foo')
->addConstructorLookup('bar');
$obj = $this->_container->lookup('one');
$this->assertSame('FOO', $obj->arg1);
$this->assertSame(42, $obj->arg2);
}
public function testResolvedDependenciesCanBeLookedUp()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('one')->asNewInstanceOf('One');
$this->_container->register('two')->asNewInstanceOf('One')
->withDependencies(array('one', 'foo'));
$deps = $this->_container->createDependenciesFor('two');
$this->assertEquals(
array($this->_container->lookup('one'), 'FOO'), $deps
);
}
public function testArrayOfDependenciesCanBeSpecified()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('one')->asNewInstanceOf('One');
$this->_container->register('two')->asNewInstanceOf('One')
->withDependencies(array(array('one', 'foo'), 'foo'));
$obj = $this->_container->lookup('two');
$this->assertEquals(array($this->_container->lookup('one'), 'FOO'), $obj->arg1);
$this->assertSame('FOO', $obj->arg2);
}
public function testAliasCanBeSet()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('bar')->asAliasOf('foo');
$this->assertSame('FOO', $this->_container->lookup('bar'));
}
public function testAliasOfAliasCanBeSet()
{
$this->_container->register('foo')->asValue('FOO');
$this->_container->register('bar')->asAliasOf('foo');
$this->_container->register('zip')->asAliasOf('bar');
$this->_container->register('button')->asAliasOf('zip');
$this->assertSame('FOO', $this->_container->lookup('button'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment