Best Prophecy code snippet using or.should
ExtensionSupportTest.php
Source:ExtensionSupportTest.php
...10 public function testExtensionHandlersAreSortedAsNeeded()11 {12 $buf = $this->getBuffer();13 $smtp = $this->getTransport($buf);14 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();15 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();16 $ext1->shouldReceive('getHandledKeyword')17 ->zeroOrMoreTimes()18 ->andReturn('AUTH');19 $ext1->shouldReceive('getPriorityOver')20 ->zeroOrMoreTimes()21 ->with('STARTTLS')22 ->andReturn(1);23 $ext2->shouldReceive('getHandledKeyword')24 ->zeroOrMoreTimes()25 ->andReturn('STARTTLS');26 $ext2->shouldReceive('getPriorityOver')27 ->zeroOrMoreTimes()28 ->with('AUTH')29 ->andReturn(-1);30 $this->finishBuffer($buf);31 $smtp->setExtensionHandlers([$ext1, $ext2]);32 $this->assertEquals([$ext2, $ext1], $smtp->getExtensionHandlers());33 }34 public function testHandlersAreNotifiedOfParams()35 {36 $buf = $this->getBuffer();37 $smtp = $this->getTransport($buf);38 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();39 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();40 $buf->shouldReceive('readLine')41 ->once()42 ->with(0)43 ->andReturn("220 server.com foo\r\n");44 $buf->shouldReceive('write')45 ->once()46 ->with('~^EHLO .*?\r\n$~D')47 ->andReturn(1);48 $buf->shouldReceive('readLine')49 ->once()50 ->with(1)51 ->andReturn("250-ServerName.tld\r\n");52 $buf->shouldReceive('readLine')53 ->once()54 ->with(1)55 ->andReturn("250-AUTH PLAIN LOGIN\r\n");56 $buf->shouldReceive('readLine')57 ->once()58 ->with(1)59 ->andReturn("250 SIZE=123456\r\n");60 $ext1->shouldReceive('getHandledKeyword')61 ->zeroOrMoreTimes()62 ->andReturn('AUTH');63 $ext1->shouldReceive('setKeywordParams')64 ->once()65 ->with(['PLAIN', 'LOGIN']);66 $ext2->shouldReceive('getHandledKeyword')67 ->zeroOrMoreTimes()68 ->andReturn('SIZE');69 $ext2->shouldReceive('setKeywordParams')70 ->zeroOrMoreTimes()71 ->with(['123456']);72 $this->finishBuffer($buf);73 $smtp->setExtensionHandlers([$ext1, $ext2]);74 $smtp->start();75 }76 public function testSupportedExtensionHandlersAreRunAfterEhlo()77 {78 $buf = $this->getBuffer();79 $smtp = $this->getTransport($buf);80 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();81 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();82 $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();83 $buf->shouldReceive('readLine')84 ->once()85 ->with(0)86 ->andReturn("220 server.com foo\r\n");87 $buf->shouldReceive('write')88 ->once()89 ->with('~^EHLO .*?\r\n$~D')90 ->andReturn(1);91 $buf->shouldReceive('readLine')92 ->once()93 ->with(1)94 ->andReturn("250-ServerName.tld\r\n");95 $buf->shouldReceive('readLine')96 ->once()97 ->with(1)98 ->andReturn("250-AUTH PLAIN LOGIN\r\n");99 $buf->shouldReceive('readLine')100 ->once()101 ->with(1)102 ->andReturn("250 SIZE=123456\r\n");103 $ext1->shouldReceive('getHandledKeyword')104 ->zeroOrMoreTimes()105 ->andReturn('AUTH');106 $ext1->shouldReceive('afterEhlo')107 ->once()108 ->with($smtp);109 $ext2->shouldReceive('getHandledKeyword')110 ->zeroOrMoreTimes()111 ->andReturn('SIZE');112 $ext2->shouldReceive('afterEhlo')113 ->zeroOrMoreTimes()114 ->with($smtp);115 $ext3->shouldReceive('getHandledKeyword')116 ->zeroOrMoreTimes()117 ->andReturn('STARTTLS');118 $ext3->shouldReceive('afterEhlo')119 ->never()120 ->with($smtp);121 $this->finishBuffer($buf);122 $smtp->setExtensionHandlers([$ext1, $ext2, $ext3]);123 $smtp->start();124 }125 public function testExtensionsCanModifyMailFromParams()126 {127 $buf = $this->getBuffer();128 $dispatcher = $this->createEventDispatcher();129 $smtp = new Swift_Transport_EsmtpTransport($buf, [], $dispatcher, 'example.org');130 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();131 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();132 $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();133 $message = $this->createMessage();134 $message->shouldReceive('getFrom')135 ->zeroOrMoreTimes()136 ->andReturn(['me@domain' => 'Me']);137 $message->shouldReceive('getTo')138 ->zeroOrMoreTimes()139 ->andReturn(['foo@bar' => null]);140 $buf->shouldReceive('readLine')141 ->once()142 ->with(0)143 ->andReturn("220 server.com foo\r\n");144 $buf->shouldReceive('write')145 ->once()146 ->with('~^EHLO .*?\r\n$~D')147 ->andReturn(1);148 $buf->shouldReceive('readLine')149 ->once()150 ->with(1)151 ->andReturn("250-ServerName.tld\r\n");152 $buf->shouldReceive('readLine')153 ->once()154 ->with(1)155 ->andReturn("250-AUTH PLAIN LOGIN\r\n");156 $buf->shouldReceive('readLine')157 ->once()158 ->with(1)159 ->andReturn("250 SIZE=123456\r\n");160 $buf->shouldReceive('write')161 ->once()162 ->with("MAIL FROM:<me@domain> FOO ZIP\r\n")163 ->andReturn(2);164 $buf->shouldReceive('readLine')165 ->once()166 ->with(2)167 ->andReturn("250 OK\r\n");168 $buf->shouldReceive('write')169 ->once()170 ->with("RCPT TO:<foo@bar>\r\n")171 ->andReturn(3);172 $buf->shouldReceive('readLine')173 ->once()174 ->with(3)175 ->andReturn("250 OK\r\n");176 $this->finishBuffer($buf);177 $ext1->shouldReceive('getHandledKeyword')178 ->zeroOrMoreTimes()179 ->andReturn('AUTH');180 $ext1->shouldReceive('getMailParams')181 ->once()182 ->andReturn('FOO');183 $ext1->shouldReceive('getPriorityOver')184 ->zeroOrMoreTimes()185 ->with('STARTTLS')186 ->andReturn(1);187 $ext1->shouldReceive('getPriorityOver')188 ->zeroOrMoreTimes()189 ->with('SIZE')190 ->andReturn(-1);191 $ext2->shouldReceive('getHandledKeyword')192 ->zeroOrMoreTimes()193 ->andReturn('SIZE');194 $ext2->shouldReceive('getMailParams')195 ->once()196 ->andReturn('ZIP');197 $ext2->shouldReceive('getPriorityOver')198 ->zeroOrMoreTimes()199 ->with('AUTH')200 ->andReturn(1);201 $ext2->shouldReceive('getPriorityOver')202 ->zeroOrMoreTimes()203 ->with('STARTTLS')204 ->andReturn(1);205 $ext3->shouldReceive('getHandledKeyword')206 ->zeroOrMoreTimes()207 ->andReturn('STARTTLS');208 $ext3->shouldReceive('getMailParams')209 ->never();210 $ext3->shouldReceive('getPriorityOver')211 ->zeroOrMoreTimes()212 ->with('AUTH')213 ->andReturn(-1);214 $ext3->shouldReceive('getPriorityOver')215 ->zeroOrMoreTimes()216 ->with('SIZE')217 ->andReturn(-1);218 $smtp->setExtensionHandlers([$ext1, $ext2, $ext3]);219 $smtp->start();220 $smtp->send($message);221 }222 public function testExtensionsCanModifyRcptParams()223 {224 $buf = $this->getBuffer();225 $dispatcher = $this->createEventDispatcher();226 $smtp = new Swift_Transport_EsmtpTransport($buf, [], $dispatcher, 'example.org');227 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();228 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();229 $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();230 $message = $this->createMessage();231 $message->shouldReceive('getFrom')232 ->zeroOrMoreTimes()233 ->andReturn(['me@domain' => 'Me']);234 $message->shouldReceive('getTo')235 ->zeroOrMoreTimes()236 ->andReturn(['foo@bar' => null]);237 $buf->shouldReceive('readLine')238 ->once()239 ->with(0)240 ->andReturn("220 server.com foo\r\n");241 $buf->shouldReceive('write')242 ->once()243 ->with('~^EHLO .+?\r\n$~D')244 ->andReturn(1);245 $buf->shouldReceive('readLine')246 ->once()247 ->with(1)248 ->andReturn("250-ServerName.tld\r\n");249 $buf->shouldReceive('readLine')250 ->once()251 ->with(1)252 ->andReturn("250-AUTH PLAIN LOGIN\r\n");253 $buf->shouldReceive('readLine')254 ->once()255 ->with(1)256 ->andReturn("250 SIZE=123456\r\n");257 $buf->shouldReceive('write')258 ->once()259 ->with("MAIL FROM:<me@domain>\r\n")260 ->andReturn(2);261 $buf->shouldReceive('readLine')262 ->once()263 ->with(2)264 ->andReturn("250 OK\r\n");265 $buf->shouldReceive('write')266 ->once()267 ->with("RCPT TO:<foo@bar> FOO ZIP\r\n")268 ->andReturn(3);269 $buf->shouldReceive('readLine')270 ->once()271 ->with(3)272 ->andReturn("250 OK\r\n");273 $this->finishBuffer($buf);274 $ext1->shouldReceive('getHandledKeyword')275 ->zeroOrMoreTimes()276 ->andReturn('AUTH');277 $ext1->shouldReceive('getRcptParams')278 ->once()279 ->andReturn('FOO');280 $ext1->shouldReceive('getPriorityOver')281 ->zeroOrMoreTimes()282 ->with('STARTTLS')283 ->andReturn(1);284 $ext1->shouldReceive('getPriorityOver')285 ->zeroOrMoreTimes()286 ->with('SIZE')287 ->andReturn(-1);288 $ext2->shouldReceive('getHandledKeyword')289 ->zeroOrMoreTimes()290 ->andReturn('SIZE');291 $ext2->shouldReceive('getRcptParams')292 ->once()293 ->andReturn('ZIP');294 $ext2->shouldReceive('getPriorityOver')295 ->zeroOrMoreTimes()296 ->with('STARTTLS')297 ->andReturn(1);298 $ext2->shouldReceive('getPriorityOver')299 ->zeroOrMoreTimes()300 ->with('AUTH')301 ->andReturn(1);302 $ext3->shouldReceive('getHandledKeyword')303 ->zeroOrMoreTimes()304 ->andReturn('STARTTLS');305 $ext3->shouldReceive('getRcptParams')306 ->never();307 $ext3->shouldReceive('getPriorityOver')308 ->zeroOrMoreTimes()309 ->with('AUTH')310 ->andReturn(-1);311 $ext3->shouldReceive('getPriorityOver')312 ->zeroOrMoreTimes()313 ->with('SIZE')314 ->andReturn(-1);315 $smtp->setExtensionHandlers([$ext1, $ext2, $ext3]);316 $smtp->start();317 $smtp->send($message);318 }319 public function testExtensionsAreNotifiedOnCommand()320 {321 $buf = $this->getBuffer();322 $smtp = $this->getTransport($buf);323 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();324 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();325 $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();326 $buf->shouldReceive('readLine')327 ->once()328 ->with(0)329 ->andReturn("220 server.com foo\r\n");330 $buf->shouldReceive('write')331 ->once()332 ->with('~^EHLO .+?\r\n$~D')333 ->andReturn(1);334 $buf->shouldReceive('readLine')335 ->once()336 ->with(1)337 ->andReturn("250-ServerName.tld\r\n");338 $buf->shouldReceive('readLine')339 ->once()340 ->with(1)341 ->andReturn("250-AUTH PLAIN LOGIN\r\n");342 $buf->shouldReceive('readLine')343 ->once()344 ->with(1)345 ->andReturn("250 SIZE=123456\r\n");346 $buf->shouldReceive('write')347 ->once()348 ->with("FOO\r\n")349 ->andReturn(2);350 $buf->shouldReceive('readLine')351 ->once()352 ->with(2)353 ->andReturn("250 Cool\r\n");354 $this->finishBuffer($buf);355 $ext1->shouldReceive('getHandledKeyword')356 ->zeroOrMoreTimes()357 ->andReturn('AUTH');358 $ext1->shouldReceive('onCommand')359 ->once()360 ->with($smtp, "FOO\r\n", [250, 251], \Mockery::any(), \Mockery::any());361 $ext2->shouldReceive('getHandledKeyword')362 ->zeroOrMoreTimes()363 ->andReturn('SIZE');364 $ext2->shouldReceive('onCommand')365 ->once()366 ->with($smtp, "FOO\r\n", [250, 251], \Mockery::any(), \Mockery::any());367 $ext3->shouldReceive('getHandledKeyword')368 ->zeroOrMoreTimes()369 ->andReturn('STARTTLS');370 $ext3->shouldReceive('onCommand')371 ->never()372 ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any());373 $smtp->setExtensionHandlers([$ext1, $ext2, $ext3]);374 $smtp->start();375 $smtp->executeCommand("FOO\r\n", [250, 251]);376 }377 public function testChainOfCommandAlgorithmWhenNotifyingExtensions()378 {379 $buf = $this->getBuffer();380 $smtp = $this->getTransport($buf);381 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();382 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();383 $ext3 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();384 $buf->shouldReceive('readLine')385 ->once()386 ->with(0)387 ->andReturn("220 server.com foo\r\n");388 $buf->shouldReceive('write')389 ->once()390 ->with('~^EHLO .+?\r\n$~D')391 ->andReturn(1);392 $buf->shouldReceive('readLine')393 ->once()394 ->with(1)395 ->andReturn("250-ServerName.tld\r\n");396 $buf->shouldReceive('readLine')397 ->once()398 ->with(1)399 ->andReturn("250-AUTH PLAIN LOGIN\r\n");400 $buf->shouldReceive('readLine')401 ->once()402 ->with(1)403 ->andReturn("250 SIZE=123456\r\n");404 $buf->shouldReceive('write')405 ->never()406 ->with("FOO\r\n");407 $this->finishBuffer($buf);408 $ext1->shouldReceive('getHandledKeyword')409 ->zeroOrMoreTimes()410 ->andReturn('AUTH');411 $ext1->shouldReceive('onCommand')412 ->once()413 ->with($smtp, "FOO\r\n", [250, 251], \Mockery::any(), \Mockery::any())414 ->andReturnUsing(function ($a, $b, $c, $d, &$e) {415 $e = true;416 return '250 ok';417 });418 $ext2->shouldReceive('getHandledKeyword')419 ->zeroOrMoreTimes()420 ->andReturn('SIZE');421 $ext2->shouldReceive('onCommand')422 ->never()423 ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any());424 $ext3->shouldReceive('getHandledKeyword')425 ->zeroOrMoreTimes()426 ->andReturn('STARTTLS');427 $ext3->shouldReceive('onCommand')428 ->never()429 ->with(\Mockery::any(), \Mockery::any(), \Mockery::any(), \Mockery::any());430 $smtp->setExtensionHandlers([$ext1, $ext2, $ext3]);431 $smtp->start();432 $smtp->executeCommand("FOO\r\n", [250, 251]);433 }434 public function testExtensionsCanExposeMixinMethods()435 {436 $buf = $this->getBuffer();437 $smtp = $this->getTransport($buf);438 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing();439 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();440 $ext1->shouldReceive('getHandledKeyword')441 ->zeroOrMoreTimes()442 ->andReturn('AUTH');443 $ext1->shouldReceive('exposeMixinMethods')444 ->zeroOrMoreTimes()445 ->andReturn(['setUsername', 'setPassword']);446 $ext1->shouldReceive('setUsername')447 ->once()448 ->with('mick');449 $ext1->shouldReceive('setPassword')450 ->once()451 ->with('pass');452 $ext2->shouldReceive('getHandledKeyword')453 ->zeroOrMoreTimes()454 ->andReturn('STARTTLS');455 $this->finishBuffer($buf);456 $smtp->setExtensionHandlers([$ext1, $ext2]);457 $smtp->setUsername('mick');458 $smtp->setPassword('pass');459 }460 public function testMixinMethodsBeginningWithSetAndNullReturnAreFluid()461 {462 $buf = $this->getBuffer();463 $smtp = $this->getTransport($buf);464 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing();465 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();466 $ext1->shouldReceive('getHandledKeyword')467 ->zeroOrMoreTimes()468 ->andReturn('AUTH');469 $ext1->shouldReceive('exposeMixinMethods')470 ->zeroOrMoreTimes()471 ->andReturn(['setUsername', 'setPassword']);472 $ext1->shouldReceive('setUsername')473 ->once()474 ->with('mick')475 ->andReturn(null);476 $ext1->shouldReceive('setPassword')477 ->once()478 ->with('pass')479 ->andReturn(null);480 $ext2->shouldReceive('getHandledKeyword')481 ->zeroOrMoreTimes()482 ->andReturn('STARTTLS');483 $this->finishBuffer($buf);484 $smtp->setExtensionHandlers([$ext1, $ext2]);485 $ret = $smtp->setUsername('mick');486 $this->assertEquals($smtp, $ret);487 $ret = $smtp->setPassword('pass');488 $this->assertEquals($smtp, $ret);489 }490 public function testMixinSetterWhichReturnValuesAreNotFluid()491 {492 $buf = $this->getBuffer();493 $smtp = $this->getTransport($buf);494 $ext1 = $this->getMockery('Swift_Transport_EsmtpHandlerMixin')->shouldIgnoreMissing();495 $ext2 = $this->getMockery('Swift_Transport_EsmtpHandler')->shouldIgnoreMissing();496 $ext1->shouldReceive('getHandledKeyword')497 ->zeroOrMoreTimes()498 ->andReturn('AUTH');499 $ext1->shouldReceive('exposeMixinMethods')500 ->zeroOrMoreTimes()501 ->andReturn(['setUsername', 'setPassword']);502 $ext1->shouldReceive('setUsername')503 ->once()504 ->with('mick')505 ->andReturn('x');506 $ext1->shouldReceive('setPassword')507 ->once()508 ->with('pass')509 ->andReturn('x');510 $ext2->shouldReceive('getHandledKeyword')511 ->zeroOrMoreTimes()512 ->andReturn('STARTTLS');513 $this->finishBuffer($buf);514 $smtp->setExtensionHandlers([$ext1, $ext2]);515 $this->assertEquals('x', $smtp->setUsername('mick'));516 $this->assertEquals('x', $smtp->setPassword('pass'));517 }518}...
should
Using AI Code Generation
1class A{2public function getClassName(){3return __CLASS__;4}5}6class B extends A{7public function getClassName(){8return __CLASS__;9}10}11$obj1 = new A();12$obj2 = new B();13echo $obj1->getClassName();14echo $obj2->getClassName();15echo __FILE__;16echo __LINE__;17function myFunction(){18echo __FUNCTION__;19}20myFunction();21class MyClass{22public function myFunction(){23echo __CLASS__;24}25}26$obj = new MyClass();27$obj->myFunction();28trait MyTrait{29public function myFunction(){30echo __TRAIT__;31}32}33class MyClass{34use MyTrait;35}36$obj = new MyClass();37$obj->myFunction();38class MyClass{39public function myFunction(){40echo __METHOD__;41}42}43$obj = new MyClass();44$obj->myFunction();
should
Using AI Code Generation
1class 2{2 public function __construct(){3 $this->or = new or();4 }5 public function should($a,$b){6 $this->or->should($a,$b);7 }8}9class 1{10 public function __construct(){11 $this->and = new and();12 }13 public function and($a,$b){14 $this->and->and($a,$b);15 }16}17class 0{18 public function __construct(){19 $this->not = new not();20 }21 public function not($a){22 $this->not->not($a);23 }24}25class 3{26 public function __construct(){27 $this->if = new if();28 }29 public function if($a,$b){30 $this->if->if($a,$b);31 }32}33class 4{34 public function __construct(){35 $this->then = new then();36 }37 public function then($a,$b){38 $this->then->then($a,$b);39 }40}41class 5{42 public function __construct(){43 $this->else = new else();44 }45 public function else($a,$b){46 $this->else->else($a,$b);47 }48}49class 6{50 public function __construct(){51 $this->elseif = new elseif();52 }53 public function elseif($a,$b){54 $this->elseif->elseif($a,$b);55 }56}57class 7{58 public function __construct(){59 $this->while = new while();60 }61 public function while($a,$b){62 $this->while->while($a,$b);63 }64}65class 8{
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with should on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!