本文整理汇总了PHP中Expectations类的典型用法代码示例。如果您正苦于以下问题:PHP Expectations类的具体用法?PHP Expectations怎么用?PHP Expectations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Expectations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createMessageWithByteCount
private function _createMessageWithByteCount($bytes)
{
$this->_bytes = $bytes;
$msg = $this->_mock('Swift_Mime_Message');
$this->_checking(Expectations::create()->ignoring($msg)->toByteStream(any())->calls(array($this, '_write')));
return $msg;
}
示例2: testRegisterPluginDelegatesToTransport
public function testRegisterPluginDelegatesToTransport()
{
$plugin = $this->_createPlugin();
$transport = $this->_createTransport();
$mailer = $this->_createMailer($transport);
$this->_checking(Expectations::create()->one($transport)->registerPlugin($plugin));
$mailer->registerPlugin($plugin);
}
示例3: testOverridingTranslationsOnlyAddsNeededFilters
public function testOverridingTranslationsOnlyAddsNeededFilters()
{
$factory = $this->_createFactory();
$this->_checking(Expectations::create()->one($factory)->createFilter('a', 'b')->returns($this->_createFilter())->one($factory)->createFilter('x', 'y')->returns($this->_createFilter())->never($factory));
$buffer = $this->_createBuffer($factory);
$buffer->setWriteTranslations(array('a' => 'b'));
$buffer->setWriteTranslations(array('x' => 'y', 'a' => 'b'));
}
示例4: testSendingMessageRegeneratesId
public function testSendingMessageRegeneratesId()
{
$buf = $this->_getBuffer();
$sendmail = $this->_getSendmail($buf);
$message = $this->_createMessage();
$this->_checking(Expectations::create()->allowing($message)->getTo()->returns(array('foo@bar' => 'Foobar', 'zip@button' => 'Zippy'))->one($message)->generateId()->ignoring($message)->one($buf)->initialize()->one($buf)->terminate()->one($buf)->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n.."))->one($buf)->setWriteTranslations(array())->ignoring($buf));
$sendmail->setCommand('/usr/sbin/sendmail -t');
$this->assertEqual(2, $sendmail->send($message));
}
示例5: testReportingFailedBcc
public function testReportingFailedBcc()
{
$message = $this->_createMessage();
$evt = $this->_createSendEvent();
$reporter = $this->_createReporter();
$this->_checking(Expectations::create()->allowing($message)->getTo()->returns(array('foo@bar.tld' => 'Foo'))->allowing($message)->getBcc()->returns(array('zip@button' => 'Zip', 'test@test.com' => 'Test'))->allowing($evt)->getMessage()->returns($message)->allowing($evt)->getFailedRecipients()->returns(array('zip@button'))->one($reporter)->notify($message, 'foo@bar.tld', Swift_Plugins_Reporter::RESULT_PASS)->one($reporter)->notify($message, 'zip@button', Swift_Plugins_Reporter::RESULT_FAIL)->one($reporter)->notify($message, 'test@test.com', Swift_Plugins_Reporter::RESULT_PASS)->ignoring($message)->ignoring($evt));
$plugin = new Swift_Plugins_ReporterPlugin($reporter);
$plugin->sendPerformed($evt);
}
示例6: testUnbindingStreamPreventsFurtherWrites
public function testUnbindingStreamPreventsFurtherWrites()
{
$this->_initializeBuffer();
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$this->_checking(Expectations::create()->one($is1)->write('x')->one($is2)->write('x')->one($is1)->write('y'));
$this->_buffer->bind($is1);
$this->_buffer->bind($is2);
$this->_buffer->write('x');
$this->_buffer->unbind($is2);
$this->_buffer->write('y');
}
示例7: testFirstLineCanHaveShorterLength
public function testFirstLineCanHaveShorterLength()
{
$charStream = $this->_mock('Swift_CharacterStream');
$seq = $this->_sequence('byte-sequence');
$string = '';
for ($x = 0; $x < 200; ++$x) {
$char = 'a';
$string .= $char;
$this->_checking(Expectations::create()->one($charStream)->read(optional())->inSequence($seq)->returns($char));
}
$this->_checking(Expectations::create()->atLeast(1)->of($charStream)->read(optional())->inSequence($seq)->returns(false)->one($charStream)->importString($string)->ignoring($charStream)->flushContents());
$encoder = new Swift_Encoder_Rfc2231Encoder($charStream);
$encoded = $encoder->encodeString($string, 25, 75);
$this->assertEqual(str_repeat('a', 50) . "\r\n" . str_repeat('a', 75) . "\r\n" . str_repeat('a', 75), $encoded, '%s: First line should be 25 bytes shorter than the others.');
}
示例8: testClonedStreamStillReferencesSameCache
public function testClonedStreamStillReferencesSameCache()
{
$cache = $this->_createKeyCache();
$this->_checking(Expectations::create()->one($cache)->setString($this->_nsKey, 'foo', 'a', Swift_KeyCache::MODE_APPEND)->one($cache)->setString($this->_nsKey, 'foo', 'b', Swift_KeyCache::MODE_APPEND)->one($cache)->setString('test', 'bar', 'x', Swift_KeyCache::MODE_APPEND));
$stream = new Swift_KeyCache_SimpleKeyCacheInputStream();
$stream->setKeyCache($cache);
$stream->setNsKey($this->_nsKey);
$stream->setItemKey('foo');
$stream->write('a');
$stream->write('b');
$newStream = clone $stream;
$newStream->setKeyCache($cache);
$newStream->setNsKey('test');
$newStream->setItemKey('bar');
$newStream->write('x');
}
示例9: testUnbindingStreamPreventsFurtherWrites
public function testUnbindingStreamPreventsFurtherWrites()
{
$file = $this->_createFileStream($this->_testFile, true);
$is1 = $this->_createMockInputStream();
$is2 = $this->_createMockInputStream();
$this->_checking(Expectations::create()->one($is1)->write('x')->one($is2)->write('x')->one($is1)->write('y'));
$file->bind($is1);
$file->bind($is2);
$file->write('x');
$file->unbind($is2);
$file->write('y');
}
示例10: testAddingListenerTwiceDoesNotReceiveEventTwice
public function testAddingListenerTwiceDoesNotReceiveEventTwice()
{
$transport = $this->_stub('Swift_Transport');
$evt = $this->_dispatcher->createTransportChangeEvent($transport);
$listener = $this->_mock('Swift_Events_TransportChangeListener');
$this->_dispatcher->bindEventListener($listener);
$this->_dispatcher->bindEventListener($listener);
$this->_checking(Expectations::create()->one($listener)->transportStarted($evt)->never($listener)->transportStarted($evt));
$this->_dispatcher->dispatchEvent($evt, 'transportStarted');
}
示例11: testMixinSetterWhichReturnValuesAreNotFluid
public function testMixinSetterWhichReturnValuesAreNotFluid()
{
$buf = $this->_getBuffer();
$smtp = $this->_getTransport($buf);
$ext1 = $this->_mock('Swift_Transport_EsmtpHandlerMixin');
$ext2 = $this->_mock('Swift_Transport_EsmtpHandler');
$this->_checking(Expectations::create()->allowing($ext1)->getHandledKeyword()->returns('AUTH')->allowing($ext1)->exposeMixinMethods()->returns(array('setUsername', 'setPassword'))->one($ext1)->setUsername('mick')->returns('x')->one($ext1)->setPassword('pass')->returns('x')->allowing($ext2)->getHandledKeyword()->returns('STARTTLS')->ignoring($ext1)->ignoring($ext2));
$this->_finishBuffer($buf);
$smtp->setExtensionHandlers(array($ext1, $ext2));
$this->assertEqual('x', $smtp->setUsername('mick'));
$this->assertEqual('x', $smtp->setPassword('pass'));
}
示例12: _getFactory
private function _getFactory($reader)
{
$factory = $this->_mock('Swift_CharacterReaderFactory');
$this->_checking(Expectations::create()->allowing($factory)->getReaderFor('utf-8')->returns($reader));
return $factory;
}
示例13: testDataCanBeExportedToByteStream
public function testDataCanBeExportedToByteStream()
{
//See acceptance test for more detail
$is = $this->_createInputStream();
$this->_checking(Expectations::create()->atLeast(1)->of($is)->write(any())->ignoring($is));
$kcis = $this->_createKeyCacheInputStream(true);
$cache = $this->_createCache($kcis);
$cache->setString($this->_key1, 'foo', 'test', Swift_KeyCache::MODE_WRITE);
$cache->exportToByteStream($this->_key1, 'foo', $is);
}
示例14: testFirstLineLengthCanBeDifferent
public function testFirstLineLengthCanBeDifferent()
{
$input = str_repeat('a', 140);
$charStream = $this->_createCharStream();
$seq = $this->_mockery()->sequence('byte-sequence');
$exps = Expectations::create();
$exps->one($charStream)->flushContents();
$exps->one($charStream)->importString($input);
$output = '';
for ($i = 0; $i < 140; ++$i) {
$exps->one($charStream)->readBytes(optional())->inSequence($seq)->returns(array(ord('a')));
if (53 == $i || 53 + 75 == $i) {
$output .= "=\r\n";
}
$output .= 'a';
}
$exps->one($charStream)->readBytes(optional())->inSequence($seq)->returns(false);
$this->_checking($exps);
$encoder = new Swift_Encoder_QpEncoder($charStream);
$this->assertEqual($output, $encoder->encodeString($input, 22), '%s: First line should start at offset 22 so can only have max length 54');
}
示例15: testAuthenticationFailureSendRsetAndReturnFalse
public function testAuthenticationFailureSendRsetAndReturnFalse()
{
$cram = $this->_getAuthenticator();
$this->_checking(Expectations::create()->one($this->_agent)->executeCommand("AUTH CRAM-MD5\r\n", array(334))->returns('334 ' . base64_encode('<foo@bar>') . "\r\n")->one($this->_agent)->executeCommand(any(), array(235))->throws(new Swift_TransportException(""))->one($this->_agent)->executeCommand("RSET\r\n", array(250)));
$this->assertFalse($cram->authenticate($this->_agent, 'jack', 'pass'), '%s: Authentication fails, so RSET should be sent');
}