Example #1
0
 public function testSendRecordsRfcComplianceExceptionAsEntireSendFailure()
 {
     $failures = array();
     $rfcException = new Swift_RfcComplianceException('test');
     $transport = $this->_createTransport();
     $message = $this->_createMessage();
     $this->_checking(Expectations::create()->allowing($message)->getTo()->returns(array('foo&invalid' => 'Foo', '*****@*****.**' => 'Bar'))->one($transport)->send($message, reference($failures))->throws($rfcException)->ignoring($transport)->ignoring($message));
     $mailer = $this->_createMailer($transport);
     $this->assertEqual(0, $mailer->send($message, $failures), '%s: Should return 0');
     $this->assertEqual(array('foo&invalid', '*****@*****.**'), $failures, '%s: Failures should contain all addresses since the entire message failed to compile');
 }
 public function testFailureReferenceIsPassedToDelegates()
 {
     $failures = array();
     $context = new Mockery();
     $message = $context->mock('Swift_Mime_Message');
     $t1 = $context->mock('Swift_Transport');
     $con = $context->states('Connection')->startsAs('off');
     $context->checking(Expectations::create()->ignoring($message)->allowing($t1)->isStarted()->returns(false)->when($con->is('off'))->allowing($t1)->isStarted()->returns(true)->when($con->is('on'))->one($t1)->start()->when($con->isNot('on'))->then($con->is('on'))->one($t1)->send($message, reference($failures))->returns(1)->when($con->is('on'))->ignoring($t1));
     $transport = $this->_getTransport(array($t1));
     $transport->start();
     $transport->send($message, $failures);
     $context->assertIsSatisfied();
 }
Example #3
0
 public function testFailedRecipientReferenceIsPassedToTransportInBatch()
 {
     $failures = array();
     $transport = $this->_createTransport();
     $message = $this->_createMessage();
     $this->_checking(Expectations::create()->allowing($message)->getTo()->returns(array('foo@bar' => 'Foo'))->one($transport)->send($message, reference($failures))->ignoring($transport)->ignoring($message));
     $mailer = $this->_createMailer($transport);
     $mailer->batchSend($message, $failures);
 }
Example #4
0
<?php

## Возврат значения по ссылке
function &reference()
{
    $value = 3;
    while ($value > 0) {
        (yield $value);
    }
}
foreach (reference() as &$number) {
    echo --$number . ' ';
}
Example #5
0
 public function testBatchSendRecordsRfcComplianceExceptionAsIndividualRecipientFailure()
 {
     $failures = array();
     $rfcException = new Swift_RfcComplianceException('test');
     $transport = $this->_createTransport();
     $message = $this->_createMessage();
     $this->_checking(Expectations::create()->one($message)->getTo()->returns(array('foo&invalid' => 'Foo', '*****@*****.**' => 'Bar'))->one($message)->setTo(array('foo&invalid' => 'Foo'))->one($message)->getTo()->returns(array('foo&invalid' => 'Foo'))->one($message)->setTo(array('*****@*****.**' => 'Bar'))->one($transport)->send($message, reference($failures))->throws($rfcException)->one($transport)->send($message, reference($failures))->returns(1)->ignoring($transport)->ignoring($message));
     $mailer = $this->_createMailer($transport);
     $this->assertEqual(1, $mailer->batchSend($message, $failures), '%s: Should return just 1');
     $this->assertEqual(array('foo&invalid'), $failures, '%s: Failures should contain the non-compliant address');
 }