ÿØÿà JFIF ÿá Exif MM * ÿÛ C
Server IP : 199.250.214.225 / Your IP : 18.117.100.190 Web Server : Apache System : Linux vps64074.inmotionhosting.com 3.10.0-1160.105.1.vz7.214.3 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : nicngo5 ( 1001) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/nicngo5/laravelvue/vendor/swiftmailer/swiftmailer/tests/unit/Swift/Plugins/ |
Upload File : |
<?php class Swift_Plugins_BandwidthMonitorPluginTest extends \PHPUnit\Framework\TestCase { private $_monitor; private $_bytes = 0; protected function setUp() { $this->monitor = new Swift_Plugins_BandwidthMonitorPlugin(); } public function testBytesOutIncreasesWhenCommandsSent() { $evt = $this->createCommandEvent("RCPT TO:<foo@bar.com>\r\n"); $this->assertEquals(0, $this->monitor->getBytesOut()); $this->monitor->commandSent($evt); $this->assertEquals(23, $this->monitor->getBytesOut()); $this->monitor->commandSent($evt); $this->assertEquals(46, $this->monitor->getBytesOut()); } public function testBytesInIncreasesWhenResponsesReceived() { $evt = $this->createResponseEvent("250 Ok\r\n"); $this->assertEquals(0, $this->monitor->getBytesIn()); $this->monitor->responseReceived($evt); $this->assertEquals(8, $this->monitor->getBytesIn()); $this->monitor->responseReceived($evt); $this->assertEquals(16, $this->monitor->getBytesIn()); } public function testCountersCanBeReset() { $evt = $this->createResponseEvent("250 Ok\r\n"); $this->assertEquals(0, $this->monitor->getBytesIn()); $this->monitor->responseReceived($evt); $this->assertEquals(8, $this->monitor->getBytesIn()); $this->monitor->responseReceived($evt); $this->assertEquals(16, $this->monitor->getBytesIn()); $evt = $this->createCommandEvent("RCPT TO:<foo@bar.com>\r\n"); $this->assertEquals(0, $this->monitor->getBytesOut()); $this->monitor->commandSent($evt); $this->assertEquals(23, $this->monitor->getBytesOut()); $this->monitor->commandSent($evt); $this->assertEquals(46, $this->monitor->getBytesOut()); $this->monitor->reset(); $this->assertEquals(0, $this->monitor->getBytesOut()); $this->assertEquals(0, $this->monitor->getBytesIn()); } public function testBytesOutIncreasesAccordingToMessageLength() { $message = $this->createMessageWithByteCount(6); $evt = $this->createSendEvent($message); $this->assertEquals(0, $this->monitor->getBytesOut()); $this->monitor->sendPerformed($evt); $this->assertEquals(6, $this->monitor->getBytesOut()); $this->monitor->sendPerformed($evt); $this->assertEquals(12, $this->monitor->getBytesOut()); } private function createSendEvent($message) { $evt = $this->getMockBuilder('Swift_Events_SendEvent') ->disableOriginalConstructor() ->getMock(); $evt->expects($this->any()) ->method('getMessage') ->will($this->returnValue($message)); return $evt; } private function createCommandEvent($command) { $evt = $this->getMockBuilder('Swift_Events_CommandEvent') ->disableOriginalConstructor() ->getMock(); $evt->expects($this->any()) ->method('getCommand') ->will($this->returnValue($command)); return $evt; } private function createResponseEvent($response) { $evt = $this->getMockBuilder('Swift_Events_ResponseEvent') ->disableOriginalConstructor() ->getMock(); $evt->expects($this->any()) ->method('getResponse') ->will($this->returnValue($response)); return $evt; } private function createMessageWithByteCount($bytes) { $this->bytes = $bytes; $msg = $this->getMockBuilder('Swift_Mime_SimpleMessage')->disableOriginalConstructor()->getMock(); $msg->expects($this->any()) ->method('toByteStream') ->will($this->returnCallback([$this, 'write'])); /* $this->checking(Expectations::create() -> ignoring($msg)->toByteStream(any()) -> calls(array($this, 'write')) ); */ return $msg; } public function write($is) { for ($i = 0; $i < $this->bytes; ++$i) { $is->write('x'); } } }