当前位置: 首页>>代码示例>>PHP>>正文


PHP Expectations类代码示例

本文整理汇总了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;
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:7,代码来源:BandwidthMonitorPluginTest.php

示例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);
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:8,代码来源:MailerTest.php

示例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'));
 }
开发者ID:abouthalf,项目名称:archies-recipes,代码行数:8,代码来源:StreamBufferTest.php

示例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));
 }
开发者ID:abouthalf,项目名称:archies-recipes,代码行数:9,代码来源:SendmailTransportTest.php

示例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);
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:9,代码来源:ReporterPluginTest.php

示例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');
 }
开发者ID:brennantom,项目名称:hackazon,代码行数:12,代码来源:AbstractStreamBufferAcceptanceTest.php

示例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.');
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-quick-start-cn,代码行数:15,代码来源:Rfc2231EncoderTest.php

示例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');
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:16,代码来源:SimpleKeyCacheInputStreamTest.php

示例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');
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:12,代码来源:FileByteStreamAcceptanceTest.php

示例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');
 }
开发者ID:Nyaan,项目名称:meintagebuchonline,代码行数:10,代码来源:SimpleEventDispatcherTest.php

示例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'));
 }
开发者ID:Nyaan,项目名称:meintagebuchonline,代码行数:12,代码来源:ExtensionSupportTest.php

示例12: _getFactory

 private function _getFactory($reader)
 {
     $factory = $this->_mock('Swift_CharacterReaderFactory');
     $this->_checking(Expectations::create()->allowing($factory)->getReaderFor('utf-8')->returns($reader));
     return $factory;
 }
开发者ID:ningcaichen,项目名称:laravel-4.1-quick-start-cn,代码行数:6,代码来源:ArrayCharacterStreamTest.php

示例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);
 }
开发者ID:mahersafadi,项目名称:joindin-api,代码行数:10,代码来源:ArrayKeyCacheTest.php

示例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');
 }
开发者ID:guitarooman14,项目名称:hackazon,代码行数:21,代码来源:QpEncoderTest.php

示例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');
 }
开发者ID:abouthalf,项目名称:archies-recipes,代码行数:6,代码来源:CramMd5AuthenticatorTest.php


注:本文中的Expectations类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。