How to use shuntParentClassCalls method of generator class

Best Atoum code snippet using generator.shuntParentClassCalls

FileAdapter.php

Source:FileAdapter.php Github

copy

Full Screen

...38 });39 }40 public function testFileAdapterDeleteQueue()41 {42 $this->mockGenerator->shuntParentClassCalls();43 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;44 $this->mockGenerator->unshuntParentClassCalls();45 $mockFinder = new \mock\Symfony\Component\Finder\Finder;46 $this->mockGenerator->orphanize('__construct');47 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;48 $this->calling($mockFs)->exists = true;49 $this->calling($mockLockHandlerFactory)->createLock = function ($repository) {50 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;51 $mockLockHandler->getMockController()->acquire = true;52 return $mockLockHandler;53 };54 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);55 $this->given($fileAdapter)56 ->class($fileAdapter->deleteQueue('testQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');57 }58 public function testFileAdapterDeleteQueueWithEmptyQueueName()59 {60 $this->mockGenerator->shuntParentClassCalls();61 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;62 $this->mockGenerator->unshuntParentClassCalls();63 $mockFinder = new \mock\Symfony\Component\Finder\Finder;64 $this->mockGenerator->orphanize('__construct');65 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;66 $this->calling($mockFs)->exists = true;67 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);68 $this->exception(function () use ($fileAdapter) {69 $fileAdapter->deleteQueue('');70 });71 }72 public function testFileAdapterDeleteQueueWithNoQueueFile()73 {74 $this->mockGenerator->shuntParentClassCalls();75 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;76 $this->mockGenerator->unshuntParentClassCalls();77 $mockFinder = new \mock\Symfony\Component\Finder\Finder;78 $this->mockGenerator->orphanize('__construct');79 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;80 $this->calling($mockFs)->exists = false;81 $this->calling($mockLockHandlerFactory)->createLock = function ($repository) {82 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;83 $mockLockHandler->getMockController()->acquire = true;84 return $mockLockHandler;85 };86 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);87 $this->exception(function () use ($fileAdapter) {88 $fileAdapter->deleteQueue('testQueue');89 });90 }91 public function testFileAdapterDeleteQueueWithLockFailed()92 {93 $this->mockGenerator->shuntParentClassCalls();94 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;95 $this->mockGenerator->unshuntParentClassCalls();96 $mockFinder = new \mock\Symfony\Component\Finder\Finder;97 $this->mockGenerator->orphanize('__construct');98 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;99 $this->calling($mockFs)->exists = true;100 $this->calling($mockLockHandlerFactory)->createLock = function ($repository) {101 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;102 $mockLockHandler->getMockController()->acquire = false;103 return $mockLockHandler;104 };105 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);106 $this->exception(function () use ($fileAdapter) {107 $fileAdapter->deleteQueue('testQueue');108 });109 }110 public function testFileAdapterCreateQueue()111 {112 $this->mockGenerator->shuntParentClassCalls();113 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;114 $this->mockGenerator->unshuntParentClassCalls();115 $mockFinder = new \mock\Symfony\Component\Finder\Finder;116 $this->mockGenerator->orphanize('__construct');117 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;118 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {119 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;120 $mockLockHandler->getMockController()->acquire = true;121 return $mockLockHandler;122 };123 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);124 $mockFs->getMockController()->exists = false;125 $this->given($fileAdapter)126 ->class($fileAdapter->createQueue('testQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');127 }128 public function testFileAdapterCreateQueueWithFsException()129 {130 $this->mockGenerator->shuntParentClassCalls();131 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;132 $this->mockGenerator->unshuntParentClassCalls();133 $mockFinder = new \mock\Symfony\Component\Finder\Finder;134 $this->mockGenerator->orphanize('__construct');135 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;136 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {137 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;138 $mockLockHandler->getMockController()->acquire = true;139 return $mockLockHandler;140 };141 $mockFs->getMockController()->exists = false;142 $mockFs->getMockController()->dumpFile = function ($repository) {143 throw new \Exception('test exception');144 };145 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);146 $this->exception(function () use ($fileAdapter) {147 $fileAdapter->createQueue('testQueue');148 });149 }150 public function testFileAdapterCreateQueueWithLockFailed()151 {152 $this->mockGenerator->shuntParentClassCalls();153 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;154 $this->mockGenerator->unshuntParentClassCalls();155 $mockFinder = new \mock\Symfony\Component\Finder\Finder;156 $this->mockGenerator->orphanize('__construct');157 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;158 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {159 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;160 $mockLockHandler->getMockController()->acquire = false;161 return $mockLockHandler;162 };163 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);164 $mockFs->getMockController()->exists = false;165 $this->exception(function () use ($fileAdapter) {166 $fileAdapter->createQueue('testQueue');167 });168 }169 public function testFileAdapterCreateQueueWithEmptyQueueName()170 {171 $this->mockGenerator->shuntParentClassCalls();172 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;173 $this->mockGenerator->unshuntParentClassCalls();174 $mockFinder = new \mock\Symfony\Component\Finder\Finder;175 $this->mockGenerator->orphanize('__construct');176 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;177 $this->calling($mockFs)->exists = true;178 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);179 $this->exception(function () use ($fileAdapter) {180 $fileAdapter->createQueue('');181 });182 }183 public function testFileAdapterCreateQueueWithExistingQueue()184 {185 $this->mockGenerator->shuntParentClassCalls();186 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;187 $this->mockGenerator->unshuntParentClassCalls();188 $mockFinder = new \mock\Symfony\Component\Finder\Finder;189 $this->mockGenerator->orphanize('__construct');190 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;191 $mockFs->getMockController()->exists = true;192 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);193 $this->exception(function () use ($fileAdapter) {194 $fileAdapter->createQueue('testQueue');195 });196 }197 public function testFileAdapterCreateQueueWithSpaceIngQueueName()198 {199 $this->mockGenerator->shuntParentClassCalls();200 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;201 $this->mockGenerator->unshuntParentClassCalls();202 $mockFinder = new \mock\Symfony\Component\Finder\Finder;203 $this->mockGenerator->orphanize('__construct');204 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;205 $mockFs->getMockController()->exists = false;206 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);207 $this->exception(function () use ($fileAdapter) {208 $fileAdapter->createQueue('test Queue');209 });210 }211 public function testFileAdapterPurgeQueue()212 {213 $this->mockGenerator->shuntParentClassCalls();214 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;215 $this->mockGenerator->unshuntParentClassCalls();216 $mockFinder = new \mock\Symfony\Component\Finder\Finder;217 $this->mockGenerator->orphanize('__construct');218 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;219 $priorityHandler = new ThreeLevelPriorityHandler();220 $mockFs->getMockController()->exists = true;221 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {222 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;223 $mockLockHandler->getMockController()->acquire = true;224 return $mockLockHandler;225 };226 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {227 $files = [];228 $priorities = $priorityHandler->getAll();229 foreach ($priorities as $priority) {230 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;231 }232 $mocksSplFileInfo = [];233 foreach ($files as $file) {234 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');235 $mockSplFileInfo->getMockController()->getExtension = function () {236 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;237 };238 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {239 return $file;240 };241 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {242 return '/tmp/test/' . $file;243 };244 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {245 return '{"queue":[]}';246 };247 $mocksSplFileInfo[] = $mockSplFileInfo;248 }249 return new ArrayIterator($mocksSplFileInfo);250 };251 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);252 $this->given($fileAdapter)253 ->class($fileAdapter->purgeQueue('testQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');254 }255 public function testFileAdapterPurgeQueueWithNoQueueFile()256 {257 $this->mockGenerator->shuntParentClassCalls();258 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;259 $this->mockGenerator->unshuntParentClassCalls();260 $mockFinder = new \mock\Symfony\Component\Finder\Finder;261 $this->mockGenerator->orphanize('__construct');262 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;263 $mockFs->getMockController()->exists = false;264 $FileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);265 $this->exception(function () use ($FileAdapter) {266 $FileAdapter->purgeQueue('testQueue');267 });268 }269 public function testFileAdapterPurgeQueueWithEmptyQueueName()270 {271 $this->mockGenerator->shuntParentClassCalls();272 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;273 $this->mockGenerator->unshuntParentClassCalls();274 $mockFinder = new \mock\Symfony\Component\Finder\Finder;275 $this->mockGenerator->orphanize('__construct');276 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;277 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);278 $this->exception(function () use ($fileAdapter) {279 $fileAdapter->purgeQueue('');280 });281 }282 public function testFileAdapterPurgeQueueWithLockFailed()283 {284 $this->mockGenerator->shuntParentClassCalls();285 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;286 $this->mockGenerator->unshuntParentClassCalls();287 $mockFinder = new \mock\Symfony\Component\Finder\Finder;288 $this->mockGenerator->orphanize('__construct');289 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;290 $mockFs->getMockController()->exists = true;291 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {292 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;293 $mockLockHandler->getMockController()->acquire = false;294 return $mockLockHandler;295 };296 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);297 $this->exception(function () use ($fileAdapter) {298 $fileAdapter->purgeQueue('testQueue');299 });300 }301 public function testFileAdapterPurgeQueueWithEmptyQueueContent()302 {303 $this->mockGenerator->shuntParentClassCalls();304 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;305 $this->mockGenerator->unshuntParentClassCalls();306 $mockFinder = new \mock\Symfony\Component\Finder\Finder;307 $this->mockGenerator->orphanize('__construct');308 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;309 $priorityHandler = new ThreeLevelPriorityHandler();310 $mockFs->getMockController()->exists = true;311 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {312 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;313 $mockLockHandler->getMockController()->acquire = true;314 return $mockLockHandler;315 };316 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {317 $files = [];318 $priorities = $priorityHandler->getAll();319 foreach ($priorities as $priority) {320 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;321 }322 $mocksSplFileInfo = [];323 foreach ($files as $file) {324 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');325 $mockSplFileInfo->getMockController()->getExtension = function () {326 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;327 };328 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {329 return $file;330 };331 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {332 return '/tmp/test/' . $file;333 };334 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {335 return '';336 };337 $mocksSplFileInfo[] = $mockSplFileInfo;338 }339 return new ArrayIterator($mocksSplFileInfo);340 };341 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);342 $this->exception(function () use ($fileAdapter) {343 $fileAdapter->purgeQueue('testQueue');344 });345 }346 public function testFileAdapterPurgeQueueWithBadQueueContent()347 {348 $this->mockGenerator->shuntParentClassCalls();349 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;350 $this->mockGenerator->unshuntParentClassCalls();351 $mockFinder = new \mock\Symfony\Component\Finder\Finder;352 $this->mockGenerator->orphanize('__construct');353 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;354 $priorityHandler = new ThreeLevelPriorityHandler();355 $mockFs->getMockController()->exists = true;356 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {357 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;358 $mockLockHandler->getMockController()->acquire = true;359 return $mockLockHandler;360 };361 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {362 $files = [];363 $priorities = $priorityHandler->getAll();364 foreach ($priorities as $priority) {365 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;366 }367 $mocksSplFileInfo = [];368 foreach ($files as $file) {369 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');370 $mockSplFileInfo->getMockController()->getExtension = function () {371 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;372 };373 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {374 return $file;375 };376 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {377 return '/tmp/test/' . $file;378 };379 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {380 return '{"bad":[]}';381 };382 $mocksSplFileInfo[] = $mockSplFileInfo;383 }384 return new ArrayIterator($mocksSplFileInfo);385 };386 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);387 $this->exception(function () use ($fileAdapter) {388 $fileAdapter->purgeQueue('testQueue');389 });390 }391 public function testFileAdapterIsEmptyWithEmptyQueue()392 {393 $this->mockGenerator->shuntParentClassCalls();394 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;395 $this->mockGenerator->unshuntParentClassCalls();396 $mockFinder = new \mock\Symfony\Component\Finder\Finder;397 $this->mockGenerator->orphanize('__construct');398 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;399 $priorityHandler = new ThreeLevelPriorityHandler();400 $mockFs->getMockController()->exists = true;401 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {402 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;403 $mockLockHandler->getMockController()->acquire = true;404 return $mockLockHandler;405 };406 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {407 $files = [];408 $priorities = $priorityHandler->getAll();409 foreach ($priorities as $priority) {410 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;411 }412 $mocksSplFileInfo = [];413 foreach ($files as $file) {414 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');415 $mockSplFileInfo->getMockController()->getExtension = function () {416 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;417 };418 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {419 return $file;420 };421 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {422 return '/tmp/test/' . $file;423 };424 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {425 return '{"queue":[]}';426 };427 $mocksSplFileInfo[] = $mockSplFileInfo;428 }429 return new ArrayIterator($mocksSplFileInfo);430 };431 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);432 $this433 ->given($fileAdapter)434 ->boolean($fileAdapter->isEmpty('testQueue'))435 ->isTrue();436 }437 public function testFileAdapterIsEmptyWithNoEmptyQueue()438 {439 $this->mockGenerator->shuntParentClassCalls();440 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;441 $this->mockGenerator->unshuntParentClassCalls();442 $mockFinder = new \mock\Symfony\Component\Finder\Finder;443 $this->mockGenerator->orphanize('__construct');444 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;445 $priorityHandler = new ThreeLevelPriorityHandler();446 $mockFs->getMockController()->exists = true;447 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {448 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;449 $mockLockHandler->getMockController()->acquire = true;450 return $mockLockHandler;451 };452 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {453 $files = [];454 $priorities = $priorityHandler->getAll();455 foreach ($priorities as $priority) {456 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;457 }458 $mocksSplFileInfo = [];459 foreach ($files as $file) {460 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');461 $mockSplFileInfo->getMockController()->getExtension = function () { return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION; };462 $mockSplFileInfo->getMockController()->getRelativePathname = function () use($file) { return $file; };463 $mockSplFileInfo->getMockController()->getPathname = function () use($file) { return '/tmp/test/' . $file; };464 $mockSplFileInfo->getMockController()->getContents = function () use($file) { return '{"queue":[{"id":"testQueue-HIGH559f77704e87c5.40358915","time-in-flight":null, "delayed-until":null,"time-in-flight":null, "delayed-until":null,"Body":"s:12:\"Test message\";"}]}'; };465 $mocksSplFileInfo[] = $mockSplFileInfo;466 }467 return new ArrayIterator($mocksSplFileInfo);468 };469 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);470 $this471 ->given($fileAdapter)472 ->boolean($fileAdapter->isEmpty('testQueue'))473 ->isFalse();474 }475 public function testFileAdapterIsEmptyWithEmptyQueueName()476 {477 $this->mockGenerator->shuntParentClassCalls();478 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;479 $this->mockGenerator->unshuntParentClassCalls();480 $mockFinder = new \mock\Symfony\Component\Finder\Finder;481 $this->mockGenerator->orphanize('__construct');482 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;483 $mockFs->getMockController()->exists = true;484 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);485 $this->exception(function () use ($fileAdapter) {486 $fileAdapter->isEmpty('');487 });488 }489 public function testFileAdapterIsEmptyWithNoQueueFile()490 {491 $this->mockGenerator->shuntParentClassCalls();492 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;493 $this->mockGenerator->unshuntParentClassCalls();494 $mockFinder = new \mock\Symfony\Component\Finder\Finder;495 $this->mockGenerator->orphanize('__construct');496 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;497 $mockFs->getMockController()->exists = false;498 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);499 $this->exception(function () use ($fileAdapter) {500 $fileAdapter->isEmpty('testQueue');501 });502 }503 public function testFileAdapterIsEmptyWithEmptyQueueContent()504 {505 $this->mockGenerator->shuntParentClassCalls();506 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;507 $this->mockGenerator->unshuntParentClassCalls();508 $mockFinder = new \mock\Symfony\Component\Finder\Finder;509 $this->mockGenerator->orphanize('__construct');510 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;511 $priorityHandler = new ThreeLevelPriorityHandler();512 $mockFs->getMockController()->exists = true;513 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {514 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;515 $mockLockHandler->getMockController()->acquire = true;516 return $mockLockHandler;517 };518 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {519 $files = [];520 $priorities = $priorityHandler->getAll();521 foreach ($priorities as $priority) {522 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;523 }524 $mocksSplFileInfo = [];525 foreach ($files as $file) {526 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');527 $mockSplFileInfo->getMockController()->getExtension = function () {528 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;529 };530 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {531 return $file;532 };533 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {534 return '/tmp/test/' . $file;535 };536 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {537 return '';538 };539 $mocksSplFileInfo[] = $mockSplFileInfo;540 }541 return new ArrayIterator($mocksSplFileInfo);542 };543 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);544 $this->exception(function () use ($fileAdapter) {545 $fileAdapter->isEmpty('testQueue');546 });547 }548 public function testFileAdapterIsEmptyWithBadQueueContent()549 {550 $this->mockGenerator->shuntParentClassCalls();551 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;552 $this->mockGenerator->unshuntParentClassCalls();553 $mockFinder = new \mock\Symfony\Component\Finder\Finder;554 $this->mockGenerator->orphanize('__construct');555 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;556 $priorityHandler = new ThreeLevelPriorityHandler();557 $mockFs->getMockController()->exists = true;558 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {559 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;560 $mockLockHandler->getMockController()->acquire = true;561 return $mockLockHandler;562 };563 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {564 $files = [];565 $priorities = $priorityHandler->getAll();566 foreach ($priorities as $priority) {567 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;568 }569 $mocksSplFileInfo = [];570 foreach ($files as $file) {571 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');572 $mockSplFileInfo->getMockController()->getExtension = function () {573 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;574 };575 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {576 return $file;577 };578 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {579 return '/tmp/test/' . $file;580 };581 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {582 return '{"bad":[]}';583 };584 $mocksSplFileInfo[] = $mockSplFileInfo;585 }586 return new ArrayIterator($mocksSplFileInfo);587 };588 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);589 $this->exception(function () use ($fileAdapter) {590 $fileAdapter->isEmpty('testQueue');591 });592 }593 public function testFileAdapterListQueues()594 {595 $this->mockGenerator->shuntParentClassCalls();596 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;597 $this->mockGenerator->unshuntParentClassCalls();598 $mockFinder = new \mock\Symfony\Component\Finder\Finder;599 $this->mockGenerator->orphanize('__construct');600 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;601 $priorityHandler = new ThreeLevelPriorityHandler();602 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {603 $files = [];604 $priorities = $priorityHandler->getAll();605 foreach ($priorities as $priority) {606 $files[] = 'testOneQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;607 $files[] = 'prefixTestTwoQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;608 $files[] = 'testTwoQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;609 $files[] = 'testThreeQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;610 }611 $mocksSplFileInfo = [];612 foreach ($files as $file) {613 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');614 $mockSplFileInfo->getMockController()->getExtension = function () {615 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;616 };617 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {618 return $file;619 };620 $mocksSplFileInfo[] = $mockSplFileInfo;621 }622 return new ArrayIterator($mocksSplFileInfo);623 };624 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);625 $this626 ->given($fileAdapter)627 ->array($fileAdapter->listQueues())628 ->containsValues(['testOneQueue', 'testTwoQueue', 'testThreeQueue']);629 }630 public function testFileAdapterListQueuesWithPrefix()631 {632 $this->mockGenerator->shuntParentClassCalls();633 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;634 $this->mockGenerator->unshuntParentClassCalls();635 $mockFinder = new \mock\Symfony\Component\Finder\Finder;636 $this->mockGenerator->orphanize('__construct');637 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;638 $priorityHandler = new ThreeLevelPriorityHandler();639 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {640 $files = [];641 $priorities = $priorityHandler->getAll();642 foreach ($priorities as $priority) {643 $files[] = 'testOneQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;644 $files[] = 'prefixTestTwoQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;645 $files[] = 'testTwoQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;646 $files[] = 'prefixTestOneQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;647 }648 $mocksSplFileInfo = [];649 foreach ($files as $file) {650 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');651 $mockSplFileInfo->getMockController()->getExtension = function () {652 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;653 };654 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {655 return $file;656 };657 $mocksSplFileInfo[] = $mockSplFileInfo;658 }659 return new ArrayIterator($mocksSplFileInfo);660 };661 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);662 $this663 ->given($fileAdapter)664 ->array($fileAdapter->listQueues('prefix'))665 ->containsValues(['prefixTestOneQueue', 'prefixTestTwoQueue']);666 }667 public function testFileAdapterListQueuesWithEmptyQueue()668 {669 $this->mockGenerator->shuntParentClassCalls();670 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;671 $this->mockGenerator->unshuntParentClassCalls();672 $mockFinder = new \mock\Symfony\Component\Finder\Finder;673 $this->mockGenerator->orphanize('__construct');674 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;675 $mockFinder->getMockController()->getIterator = function () {676 return new ArrayIterator([]);677 };678 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);679 $this680 ->given($fileAdapter)681 ->array($fileAdapter->listQueues())682 ->isEmpty();683 }684 public function testFileAdapterAddMessage()685 {686 $this->mockGenerator->shuntParentClassCalls();687 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;688 $this->mockGenerator->unshuntParentClassCalls();689 $mockFinder = new \mock\Symfony\Component\Finder\Finder;690 $this->mockGenerator->orphanize('__construct');691 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;692 $priorityHandler = new ThreeLevelPriorityHandler();693 $mockFs->getMockController()->exists = true;694 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {695 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;696 $mockLockHandler->getMockController()->acquire = true;697 return $mockLockHandler;698 };699 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {700 $files = [];701 $priorities = $priorityHandler->getAll();702 foreach ($priorities as $priority) {703 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;704 }705 $mocksSplFileInfo = [];706 foreach ($files as $file) {707 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');708 $mockSplFileInfo->getMockController()->getExtension = function () {709 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;710 };711 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {712 return $file;713 };714 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {715 return '/tmp/test/' . $file;716 };717 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {718 return '{"queue":[]}';719 };720 $mocksSplFileInfo[] = $mockSplFileInfo;721 }722 return new ArrayIterator($mocksSplFileInfo);723 };724 $FileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);725 $this->given($FileAdapter)726 ->class($FileAdapter->addMessage('testQueue', 'test Message one'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');727 }728 public function testFileAdapterAddMessageWithDelay()729 {730 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;731 $mockFinder = new \mock\Symfony\Component\Finder\Finder;732 $this->mockGenerator->orphanize('__construct');733 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;734 $priorityHandler = new ThreeLevelPriorityHandler();735 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);736 $mockFs->getMockController()->exists = true;737 $mockLockHandlerFactory->getMockController()->createLock = function($repository) {738 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;739 $mockLockHandler->getMockController()->acquire = true;740 return $mockLockHandler;741 };742 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {743 $files = [];744 $priorities = $priorityHandler->getAll();745 foreach ($priorities as $priority) {746 $files[] = 'testQueue'.\ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR.$priority->getName().'.'.\ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;747 }748 $mocksSplFileInfo = [];749 foreach ($files as $file) {750 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');751 $mockSplFileInfo->getMockController()->getExtension = function () { return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION; };752 $mockSplFileInfo->getMockController()->getRelativePathname = function () use($file) { return $file; };753 $mockSplFileInfo->getMockController()->getPathname = function () use($file) { return '/tmp/test/' . $file; };754 $mockSplFileInfo->getMockController()->getContents = function () use($file) { return '{"queue":[]}'; };755 $mocksSplFileInfo[] = $mockSplFileInfo;756 }757 return new ArrayIterator($mocksSplFileInfo);758 };759 $fileAdapter = $fileAdapter->addMessage('testQueue', 'test Message one', null, 1);760 sleep(1);761 $this->given($fileAdapter)762 ->class($fileAdapter)->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');763 }764 public function testFileAdapterAddMessageWithEmptyQueueName()765 {766 $this->mockGenerator->shuntParentClassCalls();767 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;768 $this->mockGenerator->unshuntParentClassCalls();769 $mockFinder = new \mock\Symfony\Component\Finder\Finder;770 $this->mockGenerator->orphanize('__construct');771 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;772 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);773 $this->exception(function () use ($fileAdapter) {774 $fileAdapter->addMessage('', '');775 });776 }777 public function testFileAdapterAddMessageWithNoQueueFile()778 {779 $this->mockGenerator->shuntParentClassCalls();780 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;781 $this->mockGenerator->unshuntParentClassCalls();782 $mockFinder = new \mock\Symfony\Component\Finder\Finder;783 $this->mockGenerator->orphanize('__construct');784 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;785 $mockFs->getMockController()->exists = false;786 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);787 $this->exception(function () use ($fileAdapter) {788 $fileAdapter->addMessage('testQueue', 'test Message one');789 });790 }791 public function testFileAdapterAddMessageWithEmptyMessage()792 {793 $this->mockGenerator->shuntParentClassCalls();794 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;795 $this->mockGenerator->unshuntParentClassCalls();796 $mockFinder = new \mock\Symfony\Component\Finder\Finder;797 $this->mockGenerator->orphanize('__construct');798 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;799 $mockFs->getMockController()->exists = true;800 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {801 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;802 $mockLockHandler->getMockController()->acquire = true;803 return $mockLockHandler;804 };805 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);806 $this->exception(function () use ($fileAdapter) {807 $fileAdapter->addMessage('testQueue', '');808 });809 }810 public function testFileAdapterAddMessageLockFailed()811 {812 $this->mockGenerator->shuntParentClassCalls();813 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;814 $this->mockGenerator->unshuntParentClassCalls();815 $mockFinder = new \mock\Symfony\Component\Finder\Finder;816 $this->mockGenerator->orphanize('__construct');817 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;818 $mockFs->getMockController()->exists = true;819 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {820 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;821 $mockLockHandler->getMockController()->acquire = false;822 return $mockLockHandler;823 };824 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);825 $this->exception(function () use ($fileAdapter) {826 $fileAdapter->addMessage('testQueue', 'test message');827 });828 }829 public function testFileAdapterAddMessageWithEmptyQueueContent()830 {831 $this->mockGenerator->shuntParentClassCalls();832 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;833 $this->mockGenerator->unshuntParentClassCalls();834 $mockFinder = new \mock\Symfony\Component\Finder\Finder;835 $this->mockGenerator->orphanize('__construct');836 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;837 $priorityHandler = new ThreeLevelPriorityHandler();838 $mockFs->getMockController()->exists = true;839 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {840 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;841 $mockLockHandler->getMockController()->acquire = true;842 return $mockLockHandler;843 };844 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {845 $files = [];846 $priorities = $priorityHandler->getAll();847 foreach ($priorities as $priority) {848 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;849 }850 $mocksSplFileInfo = [];851 foreach ($files as $file) {852 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');853 $mockSplFileInfo->getMockController()->getExtension = function () {854 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;855 };856 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {857 return $file;858 };859 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {860 return '/tmp/test/' . $file;861 };862 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {863 return '';864 };865 $mocksSplFileInfo[] = $mockSplFileInfo;866 }867 return new ArrayIterator($mocksSplFileInfo);868 };869 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);870 $this->exception(function () use ($fileAdapter) {871 $fileAdapter->addMessage('testQueue', 'test message');872 });873 }874 public function testFileAdapterAddMessageWithBadQueueContent()875 {876 $this->mockGenerator->shuntParentClassCalls();877 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;878 $this->mockGenerator->unshuntParentClassCalls();879 $mockFinder = new \mock\Symfony\Component\Finder\Finder;880 $this->mockGenerator->orphanize('__construct');881 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;882 $priorityHandler = new ThreeLevelPriorityHandler();883 $mockFs->getMockController()->exists = true;884 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {885 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;886 $mockLockHandler->getMockController()->acquire = true;887 return $mockLockHandler;888 };889 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {890 $files = [];891 $priorities = $priorityHandler->getAll();892 foreach ($priorities as $priority) {893 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;894 }895 $mocksSplFileInfo = [];896 foreach ($files as $file) {897 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');898 $mockSplFileInfo->getMockController()->getExtension = function () {899 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;900 };901 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {902 return $file;903 };904 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {905 return '/tmp/test/' . $file;906 };907 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {908 return '{"bad":[]}';909 };910 $mocksSplFileInfo[] = $mockSplFileInfo;911 }912 return new ArrayIterator($mocksSplFileInfo);913 };914 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);915 $this->exception(function () use ($fileAdapter) {916 $fileAdapter->addMessage('testQueue', 'test message');917 });918 }919 public function testFileAdapterGetNumberMessagesWithEmptyQueueName()920 {921 $this->mockGenerator->shuntParentClassCalls();922 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;923 $this->mockGenerator->unshuntParentClassCalls();924 $mockFinder = new \mock\Symfony\Component\Finder\Finder;925 $this->mockGenerator->orphanize('__construct');926 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;927 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);928 $this->exception(function () use ($fileAdapter) {929 $fileAdapter->getNumberMessages('');930 });931 }932 public function testFileAdapterGetNumberMessagesWithNoQueueFile()933 {934 $this->mockGenerator->shuntParentClassCalls();935 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;936 $this->mockGenerator->unshuntParentClassCalls();937 $mockFinder = new \mock\Symfony\Component\Finder\Finder;938 $this->mockGenerator->orphanize('__construct');939 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;940 $mockFs->getMockController()->exists = false;941 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);942 $this->exception(function () use ($fileAdapter) {943 $fileAdapter->getNumberMessages('testQueue');944 });945 }946 public function testFileAdapterGetNumberMessagesLockFailed()947 {948 $this->mockGenerator->shuntParentClassCalls();949 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;950 $this->mockGenerator->unshuntParentClassCalls();951 $mockFinder = new \mock\Symfony\Component\Finder\Finder;952 $this->mockGenerator->orphanize('__construct');953 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;954 $mockFs->getMockController()->exists = true;955 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {956 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;957 $mockLockHandler->getMockController()->acquire = false;958 return $mockLockHandler;959 };960 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);961 $this->exception(function () use ($fileAdapter) {962 $fileAdapter->getNumberMessages('testQueue');963 });964 }965 public function testFileAdapterGetNumberMessagesWithEmptyQueueContent()966 {967 $this->mockGenerator->shuntParentClassCalls();968 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;969 $this->mockGenerator->unshuntParentClassCalls();970 $mockFinder = new \mock\Symfony\Component\Finder\Finder;971 $this->mockGenerator->orphanize('__construct');972 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;973 $priorityHandler = new ThreeLevelPriorityHandler();974 $mockFs->getMockController()->exists = true;975 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {976 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;977 $mockLockHandler->getMockController()->acquire = true;978 return $mockLockHandler;979 };980 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {981 $files = [];982 $priorities = $priorityHandler->getAll();983 foreach ($priorities as $priority) {984 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;985 }986 $mocksSplFileInfo = [];987 foreach ($files as $file) {988 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');989 $mockSplFileInfo->getMockController()->getExtension = function () {990 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;991 };992 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {993 return $file;994 };995 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {996 return '/tmp/test/' . $file;997 };998 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {999 return '';1000 };1001 $mocksSplFileInfo[] = $mockSplFileInfo;1002 }1003 return new ArrayIterator($mocksSplFileInfo);1004 };1005 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1006 $this->exception(function () use ($fileAdapter) {1007 $fileAdapter->getNumberMessages('testQueue');1008 });1009 }1010 public function testFileAdapterGetNumberMessagesWithBadQueueContent()1011 {1012 $this->mockGenerator->shuntParentClassCalls();1013 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1014 $this->mockGenerator->unshuntParentClassCalls();1015 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1016 $this->mockGenerator->orphanize('__construct');1017 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1018 $priorityHandler = new ThreeLevelPriorityHandler();1019 $mockFs->getMockController()->exists = true;1020 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1021 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1022 $mockLockHandler->getMockController()->acquire = true;1023 return $mockLockHandler;1024 };1025 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1026 $files = [];1027 $priorities = $priorityHandler->getAll();1028 foreach ($priorities as $priority) {1029 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1030 }1031 $mocksSplFileInfo = [];1032 foreach ($files as $file) {1033 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1034 $mockSplFileInfo->getMockController()->getExtension = function () {1035 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1036 };1037 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {1038 return $file;1039 };1040 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {1041 return '/tmp/test/' . $file;1042 };1043 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {1044 return '{"bad":[]}';1045 };1046 $mocksSplFileInfo[] = $mockSplFileInfo;1047 }1048 return new ArrayIterator($mocksSplFileInfo);1049 };1050 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1051 $this->exception(function () use ($fileAdapter) {1052 $fileAdapter->getNumberMessages('testQueue');1053 });1054 }1055 public function testFileAdapterGetNumberMessages()1056 {1057 $this->mockGenerator->shuntParentClassCalls();1058 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1059 $this->mockGenerator->unshuntParentClassCalls();1060 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1061 $this->mockGenerator->orphanize('__construct');1062 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1063 $priorityHandler = new ThreeLevelPriorityHandler();1064 $mockFs->getMockController()->exists = true;1065 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1066 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1067 $mockLockHandler->getMockController()->acquire = true;1068 return $mockLockHandler;1069 };1070 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1071 $files = [];1072 $priorities = $priorityHandler->getAll();1073 foreach ($priorities as $priority) {1074 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1075 }1076 $mocksSplFileInfo = [];1077 foreach ($files as $file) {1078 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1079 $mockSplFileInfo->getMockController()->getExtension = function () { return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION; };1080 $mockSplFileInfo->getMockController()->getRelativePathname = function () use($file) { return $file; };1081 $mockSplFileInfo->getMockController()->getPathname = function () use($file) { return '/tmp/test/' . $file; };1082 $mockSplFileInfo->getMockController()->getContents = function () use($file) { return '{"queue":[{"id":"testQueue-HIGH559f77704e87c5.40358915","time-in-flight":null, "delayed-until":null,"delayed-until":null,"Body":"s:12:\"Test message\";"},{"id":"testQueue-HIGH559f9a97733a01.98514574","time-in-flight":null, "delayed-until":null,"Body":"s:16:\"test message two\";"}]}'; };1083 $mocksSplFileInfo[] = $mockSplFileInfo;1084 }1085 return new ArrayIterator($mocksSplFileInfo);1086 };1087 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1088 $this->given($fileAdapter)1089 ->integer($fileAdapter->getNumberMessages('testQueue'))->isEqualTo(6);1090 }1091 public function testFileAdapterGetMessagesWithEmptyQueueName()1092 {1093 $this->mockGenerator->shuntParentClassCalls();1094 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1095 $this->mockGenerator->unshuntParentClassCalls();1096 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1097 $this->mockGenerator->orphanize('__construct');1098 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1099 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1100 $this->exception(function () use ($fileAdapter) {1101 $fileAdapter->getMessages('', 1);1102 });1103 }1104 public function testFileAdapterGetMessagesWithNoQueueFile()1105 {1106 $this->mockGenerator->shuntParentClassCalls();1107 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1108 $this->mockGenerator->unshuntParentClassCalls();1109 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1110 $this->mockGenerator->orphanize('__construct');1111 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1112 $mockFs->getMockController()->exists = false;1113 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1114 $this->exception(function () use ($fileAdapter) {1115 $fileAdapter->getMessages('testQueue', 1);1116 });1117 }1118 public function testFileAdapterAddMessagesWithNoNumericNbrMsg()1119 {1120 $this->mockGenerator->shuntParentClassCalls();1121 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1122 $this->mockGenerator->unshuntParentClassCalls();1123 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1124 $this->mockGenerator->orphanize('__construct');1125 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1126 $mockFs->getMockController()->exists = true;1127 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1128 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1129 $mockLockHandler->getMockController()->acquire = true;1130 return $mockLockHandler;1131 };1132 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1133 $this->exception(function () use ($fileAdapter) {1134 $fileAdapter->getMessages('testQueue', 'toto');1135 });1136 }1137 public function testFileAdapterGetMessagesWithNotValidNumericNbrMsg()1138 {1139 $this->mockGenerator->shuntParentClassCalls();1140 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1141 $this->mockGenerator->unshuntParentClassCalls();1142 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1143 $this->mockGenerator->orphanize('__construct');1144 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1145 $mockFs->getMockController()->exists = true;1146 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1147 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1148 $mockLockHandler->getMockController()->acquire = true;1149 return $mockLockHandler;1150 };1151 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1152 $this->exception(function () use ($fileAdapter) {1153 $fileAdapter->getMessages('testQueue', -5);1154 });1155 $this->exception(function () use ($fileAdapter) {1156 $fileAdapter->getMessages('testQueue', (\ReputationVIP\QueueClient\Adapter\FileAdapter::MAX_NB_MESSAGES + 1));1157 });1158 }1159 public function testFileAdapterGetMessagesLockFailed()1160 {1161 $this->mockGenerator->shuntParentClassCalls();1162 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1163 $this->mockGenerator->unshuntParentClassCalls();1164 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1165 $this->mockGenerator->orphanize('__construct');1166 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1167 $mockFs->getMockController()->exists = true;1168 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1169 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1170 $mockLockHandler->getMockController()->acquire = false;1171 return $mockLockHandler;1172 };1173 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1174 $this->exception(function () use ($fileAdapter) {1175 $fileAdapter->getMessages('testQueue');1176 });1177 }1178 public function testFileAdapterGetMessagesWithEmptyQueueContent()1179 {1180 $this->mockGenerator->shuntParentClassCalls();1181 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1182 $this->mockGenerator->unshuntParentClassCalls();1183 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1184 $this->mockGenerator->orphanize('__construct');1185 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1186 $priorityHandler = new ThreeLevelPriorityHandler();1187 $mockFs->getMockController()->exists = true;1188 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1189 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1190 $mockLockHandler->getMockController()->acquire = true;1191 return $mockLockHandler;1192 };1193 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1194 $files = [];1195 $priorities = $priorityHandler->getAll();1196 foreach ($priorities as $priority) {1197 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1198 }1199 $mocksSplFileInfo = [];1200 foreach ($files as $file) {1201 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1202 $mockSplFileInfo->getMockController()->getExtension = function () {1203 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1204 };1205 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {1206 return $file;1207 };1208 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {1209 return '/tmp/test/' . $file;1210 };1211 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {1212 return '';1213 };1214 $mocksSplFileInfo[] = $mockSplFileInfo;1215 }1216 return new ArrayIterator($mocksSplFileInfo);1217 };1218 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1219 $this->exception(function () use ($fileAdapter) {1220 $fileAdapter->getMessages('testQueue');1221 });1222 }1223 public function testFileAdapterGetMessagesWithBadQueueContent()1224 {1225 $this->mockGenerator->shuntParentClassCalls();1226 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1227 $this->mockGenerator->unshuntParentClassCalls();1228 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1229 $this->mockGenerator->orphanize('__construct');1230 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1231 $priorityHandler = new ThreeLevelPriorityHandler();1232 $mockFs->getMockController()->exists = true;1233 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1234 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1235 $mockLockHandler->getMockController()->acquire = true;1236 return $mockLockHandler;1237 };1238 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1239 $files = [];1240 $priorities = $priorityHandler->getAll();1241 foreach ($priorities as $priority) {1242 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1243 }1244 $mocksSplFileInfo = [];1245 foreach ($files as $file) {1246 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1247 $mockSplFileInfo->getMockController()->getExtension = function () {1248 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1249 };1250 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {1251 return $file;1252 };1253 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {1254 return '/tmp/test/' . $file;1255 };1256 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {1257 return '{"bad":[]}';1258 };1259 $mocksSplFileInfo[] = $mockSplFileInfo;1260 }1261 return new ArrayIterator($mocksSplFileInfo);1262 };1263 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1264 $this->exception(function () use ($fileAdapter) {1265 $fileAdapter->getMessages('testQueue');1266 });1267 }1268 public function testFileAdapterGetMessages()1269 {1270 $this->mockGenerator->shuntParentClassCalls();1271 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1272 $this->mockGenerator->unshuntParentClassCalls();1273 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1274 $this->mockGenerator->orphanize('__construct');1275 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1276 $priorityHandler = new ThreeLevelPriorityHandler();1277 $mockFs->getMockController()->exists = true;1278 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1279 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1280 $mockLockHandler->getMockController()->acquire = true;1281 return $mockLockHandler;1282 };1283 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1284 $files = [];1285 $priorities = $priorityHandler->getAll();1286 foreach ($priorities as $priority) {1287 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1288 }1289 $mocksSplFileInfo = [];1290 foreach ($files as $file) {1291 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1292 $mockSplFileInfo->getMockController()->getExtension = function () { return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION; };1293 $mockSplFileInfo->getMockController()->getRelativePathname = function () use($file) { return $file; };1294 $mockSplFileInfo->getMockController()->getPathname = function () use($file) { return '/tmp/test/' . $file; };1295 $mockSplFileInfo->getMockController()->getContents = function () use($file) { return '{"queue":[{"id":"testQueue-HIGH559f77704e87c5.40358915","time-in-flight":null, "delayed-until":null,"Body":"s:12:\"Test message\";"},{"id":"testQueue-HIGH559f9a97733a01.98514574","time-in-flight":null, "delayed-until":null,"Body":"s:16:\"test message two\";"}]}'; };1296 $mocksSplFileInfo[] = $mockSplFileInfo;1297 }1298 return new ArrayIterator($mocksSplFileInfo);1299 };1300 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1301 $this->given($fileAdapter)1302 ->array($fileAdapter->GetMessages('testQueue', 6));1303 $this->given($fileAdapter)1304 ->array($fileAdapter->GetMessages('testQueue', 8));1305 }1306 public function testFileAdapterDeleteMessageWithEmptyQueueName()1307 {1308 $this->mockGenerator->shuntParentClassCalls();1309 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1310 $this->mockGenerator->unshuntParentClassCalls();1311 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1312 $this->mockGenerator->orphanize('__construct');1313 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1314 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1315 $this->exception(function () use ($fileAdapter) {1316 $fileAdapter->deleteMessage('', []);1317 });1318 }1319 public function testFileAdapterDeleteMessageWithNoQueueFile()1320 {1321 $this->mockGenerator->shuntParentClassCalls();1322 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1323 $this->mockGenerator->unshuntParentClassCalls();1324 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1325 $this->mockGenerator->orphanize('__construct');1326 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1327 $priorityHandler = new ThreeLevelPriorityHandler();1328 $mockFs->getMockController()->exists = false;1329 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1330 $this->exception(function () use ($fileAdapter, $priorityHandler) {1331 $fileAdapter->deleteMessage('testQueue', ['id' => 'testQueue-HIGH559f77704e87c5.40358915', 'priority' => $priorityHandler->getHighest()->getLevel()]);1332 });1333 }1334 public function testFileAdapterDeleteMessageWithNoMessage()1335 {1336 $this->mockGenerator->shuntParentClassCalls();1337 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1338 $this->mockGenerator->unshuntParentClassCalls();1339 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1340 $this->mockGenerator->orphanize('__construct');1341 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1342 $mockFs->getMockController()->exists = false;1343 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1344 $this->exception(function () use ($fileAdapter) {1345 $fileAdapter->deleteMessage('testQueue', []);1346 });1347 }1348 public function testFileAdapterDeleteMessageWithNoIdField()1349 {1350 $this->mockGenerator->shuntParentClassCalls();1351 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1352 $this->mockGenerator->unshuntParentClassCalls();1353 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1354 $this->mockGenerator->orphanize('__construct');1355 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1356 $priorityHandler = new ThreeLevelPriorityHandler();1357 $mockFs->getMockController()->exists = true;1358 $FileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1359 $this->exception(function () use ($FileAdapter, $priorityHandler) {1360 $FileAdapter->deleteMessage('testQueue', ['priority' => $priorityHandler->getHighest()->getLevel()]);1361 });1362 }1363 public function testFileAdapterDeleteMessageWithNotPriorityField()1364 {1365 $this->mockGenerator->shuntParentClassCalls();1366 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1367 $this->mockGenerator->unshuntParentClassCalls();1368 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1369 $this->mockGenerator->orphanize('__construct');1370 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1371 $mockFs->getMockController()->exists = true;1372 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1373 $this->exception(function () use ($fileAdapter) {1374 $fileAdapter->deleteMessage('testQueue', ['id' => 'testQueue-HIGH559f77704e87c5.40358915']);1375 });1376 }1377 public function testFileAdapterDeleteMessageWithBadMessageType()1378 {1379 $this->mockGenerator->shuntParentClassCalls();1380 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1381 $this->mockGenerator->unshuntParentClassCalls();1382 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1383 $this->mockGenerator->orphanize('__construct');1384 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1385 $mockFs->getMockController()->exists = true;1386 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1387 $this->exception(function () use ($fileAdapter) {1388 $fileAdapter->deleteMessage('testQueue', 'message');1389 });1390 }1391 public function testFileAdapterDeleteMessageLockFailed()1392 {1393 $this->mockGenerator->shuntParentClassCalls();1394 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1395 $this->mockGenerator->unshuntParentClassCalls();1396 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1397 $this->mockGenerator->orphanize('__construct');1398 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1399 $priorityHandler = new ThreeLevelPriorityHandler();1400 $mockFs->getMockController()->exists = true;1401 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1402 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1403 $mockLockHandler->getMockController()->acquire = false;1404 return $mockLockHandler;1405 };1406 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1407 $this->exception(function () use ($fileAdapter, $priorityHandler) {1408 $fileAdapter->deleteMessage('testQueue', ['id' => 'testQueue-HIGH559f77704e87c5.40358915', 'priority' => $priorityHandler->getHighest()->getLevel()]);1409 });1410 }1411 public function testFileAdapterDeleteMessageWithEmptyQueueContent()1412 {1413 $this->mockGenerator->shuntParentClassCalls();1414 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1415 $this->mockGenerator->unshuntParentClassCalls();1416 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1417 $this->mockGenerator->orphanize('__construct');1418 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1419 $priorityHandler = new ThreeLevelPriorityHandler();1420 $mockFs->getMockController()->exists = true;1421 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1422 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1423 $mockLockHandler->getMockController()->acquire = true;1424 return $mockLockHandler;1425 };1426 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1427 $files = [];1428 $priorities = $priorityHandler->getAll();1429 foreach ($priorities as $priority) {1430 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1431 }1432 $mocksSplFileInfo = [];1433 foreach ($files as $file) {1434 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1435 $mockSplFileInfo->getMockController()->getExtension = function () {1436 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1437 };1438 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {1439 return $file;1440 };1441 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {1442 return '/tmp/test/' . $file;1443 };1444 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {1445 return '';1446 };1447 $mocksSplFileInfo[] = $mockSplFileInfo;1448 }1449 return new ArrayIterator($mocksSplFileInfo);1450 };1451 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1452 $this->exception(function () use ($fileAdapter, $priorityHandler) {1453 $fileAdapter->deleteMessage('testQueue', ['id' => 'testQueue-HIGH559f77704e87c5.40358915', 'priority' => $priorityHandler->getHighest()->getLevel()]);1454 });1455 }1456 public function testFileAdapterDeleteMessageWithBadQueueContent()1457 {1458 $this->mockGenerator->shuntParentClassCalls();1459 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1460 $this->mockGenerator->unshuntParentClassCalls();1461 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1462 $this->mockGenerator->orphanize('__construct');1463 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1464 $priorityHandler = new ThreeLevelPriorityHandler();1465 $mockFs->getMockController()->exists = true;1466 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1467 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1468 $mockLockHandler->getMockController()->acquire = true;1469 return $mockLockHandler;1470 };1471 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1472 $files = [];1473 $priorities = $priorityHandler->getAll();1474 foreach ($priorities as $priority) {1475 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1476 }1477 $mocksSplFileInfo = [];1478 foreach ($files as $file) {1479 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1480 $mockSplFileInfo->getMockController()->getExtension = function () {1481 return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1482 };1483 $mockSplFileInfo->getMockController()->getRelativePathname = function () use ($file) {1484 return $file;1485 };1486 $mockSplFileInfo->getMockController()->getPathname = function () use ($file) {1487 return '/tmp/test/' . $file;1488 };1489 $mockSplFileInfo->getMockController()->getContents = function () use ($file) {1490 return '{"bad":[]}';1491 };1492 $mocksSplFileInfo[] = $mockSplFileInfo;1493 }1494 return new ArrayIterator($mocksSplFileInfo);1495 };1496 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1497 $this->exception(function () use ($fileAdapter, $priorityHandler) {1498 $fileAdapter->deleteMessage('testQueue', ['id' => 'testQueue-HIGH559f77704e87c5.40358915', 'priority' => $priorityHandler->getHighest()->getLevel()]);1499 });1500 }1501 public function testFileAdapterDeleteMessage()1502 {1503 $this->mockGenerator->shuntParentClassCalls();1504 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1505 $this->mockGenerator->unshuntParentClassCalls();1506 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1507 $this->mockGenerator->orphanize('__construct');1508 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1509 $priorityHandler = new ThreeLevelPriorityHandler();1510 $mockFs->getMockController()->exists = true;1511 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1512 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1513 $mockLockHandler->getMockController()->acquire = true;1514 return $mockLockHandler;1515 };1516 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1517 $files = [];1518 $priorities = $priorityHandler->getAll();1519 foreach ($priorities as $priority) {1520 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1521 }1522 $mocksSplFileInfo = [];1523 foreach ($files as $file) {1524 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1525 $mockSplFileInfo->getMockController()->getExtension = function () { return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION; };1526 $mockSplFileInfo->getMockController()->getRelativePathname = function () use($file) { return $file; };1527 $mockSplFileInfo->getMockController()->getPathname = function () use($file) { return '/tmp/test/' . $file; };1528 $mockSplFileInfo->getMockController()->getContents = function () use($file) { return '{"queue":[{"id":"testQueue-HIGH559f77704e87c5.40358915","time-in-flight":null, "delayed-until":null,"Body":"s:12:\"Test message\";"},{"id":"testQueue-HIGH559f9a97733a01.98514574","time-in-flight":null, "delayed-until":null,"Body":"s:16:\"test message two\";"}]}'; };1529 $mocksSplFileInfo[] = $mockSplFileInfo;1530 }1531 return new ArrayIterator($mocksSplFileInfo);1532 };1533 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1534 $this->given($fileAdapter)1535 ->class($fileAdapter->deleteMessage('testQueue', array('id' => 'testQueue-HIGH559f77704e87c5.40358915', 'priority' => $priorityHandler->getHighest()->getLevel())))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');1536 }1537 public function testFileAdapterRenameQueueWithEmptyParameter()1538 {1539 $this->mockGenerator->shuntParentClassCalls();1540 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1541 $this->mockGenerator->unshuntParentClassCalls();1542 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1543 $this->mockGenerator->orphanize('__construct');1544 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1545 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1546 $this->exception(function () use ($fileAdapter) {1547 $fileAdapter->renameQueue('', 'newTestQueue');1548 });1549 $this->exception(function () use ($fileAdapter) {1550 $fileAdapter->renameQueue('testQueue', '');1551 });1552 }1553 public function testFileAdapterRenameQueue()1554 {1555 $this->mockGenerator->shuntParentClassCalls();1556 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1557 $this->mockGenerator->unshuntParentClassCalls();1558 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1559 $this->mockGenerator->orphanize('__construct');1560 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1561 $priorityHandler = new ThreeLevelPriorityHandler();1562 $mockFs->getMockController()->exists = function ($queue) {1563 if (strstr($queue, 'new')) {1564 return false;1565 }1566 return true;1567 };1568 $mockLockHandlerFactory->getMockController()->createLock = function ($repository) {1569 $mockLockHandler = new \mock\Symfony\Component\Lock\LockInterface;1570 $mockLockHandler->getMockController()->acquire = true;1571 return $mockLockHandler;1572 };1573 $mockFinder->getMockController()->getIterator = function () use ($priorityHandler) {1574 $files = [];1575 $priorities = $priorityHandler->getAll();1576 foreach ($priorities as $priority) {1577 $files[] = 'testQueue' . \ReputationVIP\QueueClient\Adapter\FileAdapter::PRIORITY_SEPARATOR . $priority->getName() . '.' . \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION;1578 }1579 $mocksSplFileInfo = [];1580 foreach ($files as $file) {1581 $mockSplFileInfo = new \mock\Symfony\Component\Finder\SplFileInfo('', '', '');1582 $mockSplFileInfo->getMockController()->getExtension = function () { return \ReputationVIP\QueueClient\Adapter\FileAdapter::QUEUE_FILE_EXTENSION; };1583 $mockSplFileInfo->getMockController()->getRelativePathname = function () use($file) { return $file; };1584 $mockSplFileInfo->getMockController()->getPathname = function () use($file) { return '/tmp/test/' . $file; };1585 $mockSplFileInfo->getMockController()->getContents = function () use($file) { return '{"queue":[{"id":"testQueue-HIGH559f77704e87c5.40358915","time-in-flight":null, "delayed-until":null,"Body":"s:12:\"Test message\";"},{"id":"testQueue-HIGH559f9a97733a01.98514574","time-in-flight":null, "delayed-until":null,"Body":"s:16:\"test message two\";"}]}'; };1586 $mocksSplFileInfo[] = $mockSplFileInfo;1587 }1588 return new ArrayIterator($mocksSplFileInfo);1589 };1590 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', $priorityHandler, $mockFs, $mockFinder, $mockLockHandlerFactory);1591 $this->given($fileAdapter)1592 ->class($fileAdapter->renameQueue('testQueue', 'newTestQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');1593 }1594 public function testFileAdapterGetPriorityHandler()1595 {1596 $this->mockGenerator->shuntParentClassCalls();1597 $mockFs = new \mock\Symfony\Component\Filesystem\Filesystem;1598 $this->mockGenerator->unshuntParentClassCalls();1599 $mockFinder = new \mock\Symfony\Component\Finder\Finder;1600 $this->mockGenerator->orphanize('__construct');1601 $mockLockHandlerFactory = new \mock\Symfony\Component\Lock\Factory;1602 $fileAdapter = new \ReputationVIP\QueueClient\Adapter\FileAdapter('/tmp/test/', null, $mockFs, $mockFinder, $mockLockHandlerFactory);1603 $this->given($fileAdapter)1604 ->class($fileAdapter->getPriorityHandler())->hasInterface('\ReputationVIP\QueueClient\PriorityHandler\PriorityHandlerInterface');1605 }1606}...

Full Screen

Full Screen

SQSAdapter.php

Source:SQSAdapter.php Github

copy

Full Screen

...6{7 public function testSQSAdapterAddMessageWithEmptyQueueName()8 {9 $this->mockGenerator->orphanize('__construct');10 $this->mockGenerator->shuntParentClassCalls();11 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;12 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);13 $this->exception(function() use($sqsAdapter) {14 $sqsAdapter->addMessage('', '');15 });16 }17 public function testSQSAdapterAddMessageWithEmptyMessage()18 {19 $this->mockGenerator->orphanize('__construct');20 $this->mockGenerator->shuntParentClassCalls();21 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;22 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);23 $this->exception(function() use($sqsAdapter) {24 $sqsAdapter->addMessage('testQueue', '');25 });26 }27 public function testSQSAdapterAddMessageWithSqsException()28 {29 $this->mockGenerator->orphanize('__construct');30 $this->mockGenerator->shuntParentClassCalls();31 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;32 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;33 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);34 $this->mockGenerator->orphanize('__construct');35 $this->mockGenerator->shuntParentClassCalls();36 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;37 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {38 return $mockQueueUrlModel;39 };40 $mockSqsClient->getMockController()->sendMessage = function () use ($sqsException) {41 throw $sqsException;42 };43 $this->exception(function() use($sqsAdapter) {44 $sqsAdapter->addMessage('testQueue', 'test message');45 });46 }47 public function testSQSAdapterAddMessage()48 {49 $this->mockGenerator->orphanize('__construct');50 $this->mockGenerator->shuntParentClassCalls();51 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;52 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;53 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);54 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {55 return $mockQueueUrlModel;56 };57 $mockSqsClient->getMockController()->sendMessage = function () {58 };59 $this->given($sqsAdapter)60 ->class($sqsAdapter->addMessage('testQueue', 'test message'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');61 }62 public function testSQSAdapterAddMessages()63 {64 $this->mockGenerator->orphanize('__construct');65 $this->mockGenerator->shuntParentClassCalls();66 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;67 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;68 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);69 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {70 return $mockQueueUrlModel;71 };72 $mockSqsClient->getMockController()->sendMessageBatch = function () {};73 $this74 ->if($mockSqsClient)75 ->and($sqsAdapter->addMessages('testQueue', array_fill(0, 11, 'test message')))76 ->mock($mockSqsClient)77 ->call('sendMessageBatch')->twice();78 }79 public function testSQSAdapterAddMessagesWithEmptyMessage()80 {81 $this->mockGenerator->orphanize('__construct');82 $this->mockGenerator->shuntParentClassCalls();83 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;84 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);85 $this->exception(function() use($sqsAdapter) {86 $sqsAdapter->addMessages('testQueue', ['test message', '']);87 });88 }89 public function testSQSAdapterAddMessagesWithEmptyQueueName()90 {91 $this->mockGenerator->orphanize('__construct');92 $this->mockGenerator->shuntParentClassCalls();93 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;94 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);95 $this->exception(function() use($sqsAdapter) {96 $sqsAdapter->addMessages('', ['']);97 });98 }99 public function testSQSAdapterAddMessagesWithSqsException()100 {101 $this->mockGenerator->orphanize('__construct');102 $this->mockGenerator->shuntParentClassCalls();103 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;104 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;105 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);106 $this->mockGenerator->orphanize('__construct');107 $this->mockGenerator->shuntParentClassCalls();108 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;109 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {110 return $mockQueueUrlModel;111 };112 $mockSqsClient->getMockController()->sendMessageBatch = function () use ($sqsException) {113 throw $sqsException;114 };115 $this->exception(function() use($sqsAdapter) {116 $sqsAdapter->addMessages('testQueue', array_fill(0, 11, 'test message'));117 });118 }119 public function testSQSAdapterGetMessagesWithEmptyQueueName()120 {121 $this->mockGenerator->orphanize('__construct');122 $this->mockGenerator->shuntParentClassCalls();123 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;124 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);125 $this->exception(function() use($sqsAdapter) {126 $sqsAdapter->getMessages('');127 });128 }129 public function testSQSAdapterGetMessagesWithBadMessageNumber()130 {131 $this->mockGenerator->orphanize('__construct');132 $this->mockGenerator->shuntParentClassCalls();133 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;134 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);135 $this->exception(function() use($sqsAdapter) {136 $sqsAdapter->getMessages('testQueue', 'BadNumber');137 });138 $this->exception(function() use($sqsAdapter) {139 $sqsAdapter->getMessages('testQueue', 0);140 });141 $this->exception(function() use($sqsAdapter) {142 $sqsAdapter->getMessages('testQueue', \ReputationVIP\QueueClient\Adapter\SQSAdapter::MAX_NB_MESSAGES + 1);143 });144 }145 public function testSQSAdapterGetMessagesWithNoMessage()146 {147 $this->mockGenerator->orphanize('__construct');148 $this->mockGenerator->shuntParentClassCalls();149 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;150 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;151 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);152 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {153 return $mockQueueUrlModel;154 };155 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {156 return null;157 };158 $mockSqsClient->getMockController()->receiveMessage = function () use($mockQueueUrlModel) {159 return $mockQueueUrlModel;160 };161 $this->given($sqsAdapter)162 ->array($sqsAdapter->getMessages('testQueue', 5))->isEmpty();163 }164 public function testSQSAdapterGetMessagesWithSqsException()165 {166 $this->mockGenerator->orphanize('__construct');167 $this->mockGenerator->shuntParentClassCalls();168 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;169 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;170 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);171 $this->mockGenerator->orphanize('__construct');172 $this->mockGenerator->shuntParentClassCalls();173 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;174 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {175 return $mockQueueUrlModel;176 };177 $mockSqsClient->getMockController()->receiveMessage = function () use ($sqsException) {178 throw $sqsException;179 };180 $this->exception(function() use($sqsAdapter) {181 $sqsAdapter->getMessages('testQueue');182 });183 }184 public function testSQSAdapterGetMessages()185 {186 $this->mockGenerator->orphanize('__construct');187 $this->mockGenerator->shuntParentClassCalls();188 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;189 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;190 $priorityHandler = new ThreeLevelPriorityHandler();191 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);192 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {193 return $mockQueueUrlModel;194 };195 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {196 return [['Body' => serialize('test message one')], ['Body' => serialize('test message two')]];197 };198 $mockSqsClient->getMockController()->receiveMessage = function () use($mockQueueUrlModel) {199 return $mockQueueUrlModel;200 };201 $this->given($sqsAdapter)202 ->array($sqsAdapter->getMessages('testQueue', 6))->hasSize(6);203 }204 public function testSQSAdapterDeleteMessageWithEmptyQueueName()205 {206 $this->mockGenerator->orphanize('__construct');207 $this->mockGenerator->shuntParentClassCalls();208 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;209 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);210 $this->exception(function() use($sqsAdapter) {211 $sqsAdapter->deleteMessage('', []);212 });213 }214 public function testSQSAdapterDeleteMessageWithEmptyMessage()215 {216 $this->mockGenerator->orphanize('__construct');217 $this->mockGenerator->shuntParentClassCalls();218 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;219 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);220 $this->exception(function() use($sqsAdapter) {221 $sqsAdapter->deleteMessage('testQueue', []);222 });223 }224 public function testSQSAdapterDeleteMessageWithBadMessage()225 {226 $this->mockGenerator->orphanize('__construct');227 $this->mockGenerator->shuntParentClassCalls();228 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;229 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);230 $this->exception(function() use($sqsAdapter) {231 $sqsAdapter->deleteMessage('testQueue', 'Bad message');232 });233 }234 public function testSQSAdapterDeleteMessageWithNoMessageReceiptHandle()235 {236 $this->mockGenerator->orphanize('__construct');237 $this->mockGenerator->shuntParentClassCalls();238 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;239 $priorityHandler = new ThreeLevelPriorityHandler();240 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);241 $this->exception(function() use($sqsAdapter, $priorityHandler) {242 $sqsAdapter->deleteMessage('testQueue', ['priority' => $priorityHandler->getHighest()]);243 });244 }245 public function testSQSAdapterDeleteMessageWithNoMessagePriority()246 {247 $this->mockGenerator->orphanize('__construct');248 $this->mockGenerator->shuntParentClassCalls();249 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;250 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);251 $this->exception(function() use($sqsAdapter) {252 $sqsAdapter->deleteMessage('testQueue', ['ReceiptHandle' => 'testReceiptHandle']);253 });254 }255 public function testSQSAdapterDeleteMessageWithSqsException()256 {257 $this->mockGenerator->orphanize('__construct');258 $this->mockGenerator->shuntParentClassCalls();259 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;260 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;261 $priorityHandler = new ThreeLevelPriorityHandler();262 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);263 $this->mockGenerator->orphanize('__construct');264 $this->mockGenerator->shuntParentClassCalls();265 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;266 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {267 return $mockQueueUrlModel;268 };269 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {270 return null;271 };272 $mockSqsClient->getMockController()->deleteMessage = function () use ($sqsException) {273 throw $sqsException;274 };275 $this->exception(function() use($sqsAdapter, $priorityHandler) {276 $sqsAdapter->deleteMessage('testQueue', ['priority' => $priorityHandler->getHighest()->getLevel(), 'ReceiptHandle' => 'testReceiptHandle']);277 });278 }279 public function testSQSAdapterDeleteMessage()280 {281 $this->mockGenerator->orphanize('__construct');282 $this->mockGenerator->shuntParentClassCalls();283 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;284 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;285 $priorityHandler = new ThreeLevelPriorityHandler();286 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);287 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {288 return $mockQueueUrlModel;289 };290 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {291 return null;292 };293 $mockSqsClient->getMockController()->deleteMessage = function () use($mockQueueUrlModel) {294 return null;295 };296 $this->given($sqsAdapter)297 ->class($sqsAdapter->deleteMessage('testQueue', ['priority' => $priorityHandler->getHighest()->getLevel(), 'ReceiptHandle' => 'testReceiptHandle']))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');298 }299 public function testSQSAdapterIsEmptyWithEmptyQueueName()300 {301 $this->mockGenerator->orphanize('__construct');302 $this->mockGenerator->shuntParentClassCalls();303 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;304 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);305 $this->exception(function() use($sqsAdapter) {306 $sqsAdapter->isEmpty('');307 });308 }309 public function testSQSAdapterIsEmptyWithEmptyQueue()310 {311 $this->mockGenerator->orphanize('__construct');312 $this->mockGenerator->shuntParentClassCalls();313 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;314 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;315 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);316 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {317 return $mockQueueUrlModel;318 };319 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {320 return [['name' => 'ApproximateNumberOfMessages', 'value' => 0]];321 };322 $mockSqsClient->getMockController()->getQueueAttributes = function () use($mockQueueUrlModel) {323 return $mockQueueUrlModel;324 };325 $this->given($sqsAdapter)326 ->boolean($sqsAdapter->isEmpty('testQueue'))->IsTrue();327 }328 public function testSQSAdapterIsEmptyWithSqsException()329 {330 $this->mockGenerator->orphanize('__construct');331 $this->mockGenerator->shuntParentClassCalls();332 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;333 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;334 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);335 $this->mockGenerator->orphanize('__construct');336 $this->mockGenerator->shuntParentClassCalls();337 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;338 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {339 return $mockQueueUrlModel;340 };341 $mockSqsClient->getMockController()->getQueueAttributes = function () use ($sqsException) {342 throw $sqsException;343 };344 $this->exception(function() use($sqsAdapter) {345 $sqsAdapter->isEmpty('testQueue');346 });347 }348 public function testSQSAdapterIsEmpty()349 {350 $this->mockGenerator->orphanize('__construct');351 $this->mockGenerator->shuntParentClassCalls();352 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;353 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;354 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);355 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {356 return $mockQueueUrlModel;357 };358 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {359 return ['ApproximateNumberOfMessages' => 6];360 };361 $mockSqsClient->getMockController()->getQueueAttributes = function () use($mockQueueUrlModel) {362 return $mockQueueUrlModel;363 };364 $this->given($sqsAdapter)365 ->boolean($sqsAdapter->isEmpty('testQueue'))->IsFalse();366 }367 public function testSQSAdapterGetNumberMessagesWithEmptyQueueName()368 {369 $this->mockGenerator->orphanize('__construct');370 $this->mockGenerator->shuntParentClassCalls();371 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;372 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);373 $this->exception(function() use($sqsAdapter) {374 $sqsAdapter->getNumberMessages('');375 });376 }377 public function testSQSAdapterGetNumberMessagesWithEmptyQueue()378 {379 $this->mockGenerator->orphanize('__construct');380 $this->mockGenerator->shuntParentClassCalls();381 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;382 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;383 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);384 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {385 return $mockQueueUrlModel;386 };387 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {388 return [['name' => 'ApproximateNumberOfMessages', 'value' => 0]];389 };390 $mockSqsClient->getMockController()->getQueueAttributes = function () use($mockQueueUrlModel) {391 return $mockQueueUrlModel;392 };393 $this->given($sqsAdapter)394 ->integer($sqsAdapter->getNumberMessages('testQueue'))->IsEqualTo(0);395 }396 public function testSQSAdapterGetNumberMessagesWithSqsException()397 {398 $this->mockGenerator->orphanize('__construct');399 $this->mockGenerator->shuntParentClassCalls();400 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;401 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;402 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);403 $this->mockGenerator->orphanize('__construct');404 $this->mockGenerator->shuntParentClassCalls();405 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;406 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {407 return $mockQueueUrlModel;408 };409 $mockSqsClient->getMockController()->getQueueAttributes = function () use ($sqsException) {410 throw $sqsException;411 };412 $this->exception(function() use($sqsAdapter) {413 $sqsAdapter->getNumberMessages('testQueue');414 });415 }416 public function testSQSAdapterGetNumberMessages()417 {418 $this->mockGenerator->orphanize('__construct');419 $this->mockGenerator->shuntParentClassCalls();420 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;421 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;422 $priorityHandler =new ThreeLevelPriorityHandler();423 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);424 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {425 return $mockQueueUrlModel;426 };427 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {428 return ['ApproximateNumberOfMessages' => 6];429 };430 $mockSqsClient->getMockController()->getQueueAttributes = function () use($mockQueueUrlModel) {431 return $mockQueueUrlModel;432 };433 $this->given($sqsAdapter)434 ->integer($sqsAdapter->getNumberMessages('testQueue'))->IsEqualTo(18);435 }436 public function testSQSAdapterDeleteQueueWithEmptyQueueName()437 {438 $this->mockGenerator->orphanize('__construct');439 $this->mockGenerator->shuntParentClassCalls();440 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;441 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);442 $this->exception(function() use($sqsAdapter) {443 $sqsAdapter->deleteQueue('');444 });445 }446 public function testSQSAdapterDeleteQueueWithSqsException()447 {448 $this->mockGenerator->orphanize('__construct');449 $this->mockGenerator->shuntParentClassCalls();450 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;451 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;452 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);453 $this->mockGenerator->orphanize('__construct');454 $this->mockGenerator->shuntParentClassCalls();455 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;456 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {457 return $mockQueueUrlModel;458 };459 $mockSqsClient->getMockController()->deleteQueue = function () use ($sqsException) {460 throw $sqsException;461 };462 $this->exception(function() use($sqsAdapter) {463 $sqsAdapter->deleteQueue('testQueue');464 });465 }466 public function testSQSAdapterDeleteQueue()467 {468 $this->mockGenerator->orphanize('__construct');469 $this->mockGenerator->shuntParentClassCalls();470 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;471 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;472 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);473 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {474 return $mockQueueUrlModel;475 };476 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {477 return null;478 };479 $mockSqsClient->getMockController()->deleteQueue = function () use($mockQueueUrlModel) {480 return $mockQueueUrlModel;481 };482 $this->given($sqsAdapter)483 ->class($sqsAdapter->deleteQueue('testQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');484 }485 public function testSQSAdapterCreateQueueWithEmptyQueueName()486 {487 $this->mockGenerator->orphanize('__construct');488 $this->mockGenerator->shuntParentClassCalls();489 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;490 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);491 $this->exception(function() use($sqsAdapter) {492 $sqsAdapter->createQueue('');493 });494 }495 public function testSQSAdapterCreateQueueWithSqsException()496 {497 $this->mockGenerator->orphanize('__construct');498 $this->mockGenerator->shuntParentClassCalls();499 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;500 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;501 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);502 $this->mockGenerator->orphanize('__construct');503 $this->mockGenerator->shuntParentClassCalls();504 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;505 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {506 return $mockQueueUrlModel;507 };508 $mockSqsClient->getMockController()->createQueue = function () use ($sqsException) {509 throw $sqsException;510 };511 $this->exception(function() use($sqsAdapter) {512 $sqsAdapter->createQueue('testQueue');513 });514 }515 public function testSQSAdapterCreateQueue()516 {517 $this->mockGenerator->orphanize('__construct');518 $this->mockGenerator->shuntParentClassCalls();519 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;520 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;521 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);522 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {523 return $mockQueueUrlModel;524 };525 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {526 return null;527 };528 $mockSqsClient->getMockController()->createQueue = function () use($mockQueueUrlModel) {529 return $mockQueueUrlModel;530 };531 $this->given($sqsAdapter)532 ->class($sqsAdapter->createQueue('testQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');533 }534 public function testSQSAdapterPurgeQueueWithEmptyQueueName()535 {536 $this->mockGenerator->orphanize('__construct');537 $this->mockGenerator->shuntParentClassCalls();538 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;539 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);540 $this->exception(function() use($sqsAdapter) {541 $sqsAdapter->purgeQueue('');542 });543 }544 public function testSQSAdapterPurgeQueueWithSqsException()545 {546 $this->mockGenerator->orphanize('__construct');547 $this->mockGenerator->shuntParentClassCalls();548 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;549 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;550 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);551 $this->mockGenerator->orphanize('__construct');552 $this->mockGenerator->shuntParentClassCalls();553 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;554 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {555 return $mockQueueUrlModel;556 };557 $mockSqsClient->getMockController()->purgeQueue = function () use ($sqsException) {558 throw $sqsException;559 };560 $this->exception(function() use($sqsAdapter) {561 $sqsAdapter->purgeQueue('testQueue');562 });563 }564 public function testSQSAdapterPurgeQueue()565 {566 $this->mockGenerator->orphanize('__construct');567 $this->mockGenerator->shuntParentClassCalls();568 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;569 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;570 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);571 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {572 return $mockQueueUrlModel;573 };574 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {575 return null;576 };577 $mockSqsClient->getMockController()->purgeQueue = function () use($mockQueueUrlModel) {578 return $mockQueueUrlModel;579 };580 $this->given($sqsAdapter)581 ->class($sqsAdapter->purgeQueue('testQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');582 }583 public function testSQSAdapterListQueuesWithPrefix()584 {585 $this->mockGenerator->orphanize('__construct');586 $this->mockGenerator->shuntParentClassCalls();587 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;588 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;589 $priorityHandler = new ThreeLevelPriorityHandler();590 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);591 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {592 return $mockQueueUrlModel;593 };594 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {595 return ['prefixTestQueueOne-HIGH', 'prefixTestQueueOne-MID', 'prefixTestQueueOne-LOW', 'prefixTestQueueTwo-HIGH', 'prefixTestQueueTwo-MID', 'prefixTestQueueTwo-LOW'];596 };597 $mockSqsClient->getMockController()->listQueues = function () use($mockQueueUrlModel) {598 return $mockQueueUrlModel;599 };600 $this->given($sqsAdapter)601 ->array($sqsAdapter->listQueues('prefix'))->containsValues(['prefixTestQueueOne', 'prefixTestQueueTwo']);602 }603 public function testSQSAdapterListQueuesWithSqsException()604 {605 $this->mockGenerator->orphanize('__construct');606 $this->mockGenerator->shuntParentClassCalls();607 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;608 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;609 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);610 $this->mockGenerator->orphanize('__construct');611 $this->mockGenerator->shuntParentClassCalls();612 $sqsException = new \mock\Aws\Sqs\Exception\SqsException;613 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {614 return $mockQueueUrlModel;615 };616 $mockSqsClient->getMockController()->listQueues = function () use ($sqsException) {617 throw $sqsException;618 };619 $this->exception(function() use($sqsAdapter) {620 $sqsAdapter->listQueues();621 });622 }623 public function testSQSAdapterListQueues()624 {625 $this->mockGenerator->orphanize('__construct');626 $this->mockGenerator->shuntParentClassCalls();627 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;628 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;629 $priorityHandler = new ThreeLevelPriorityHandler();630 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);631 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {632 return $mockQueueUrlModel;633 };634 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {635 return ['testQueueOne-HIGH', 'testQueueOne-MID', 'testQueueOne-LOW', 'prefixTestQueueOne-HIGH', 'prefixTestQueueOne-MID', 'prefixTestQueueOne-LOW', 'prefixTestQueueTwo-HIGH', 'prefixTestQueueTwo-MID', 'prefixTestQueueTwo-LOW'];636 };637 $mockSqsClient->getMockController()->listQueues = function () use($mockQueueUrlModel) {638 return $mockQueueUrlModel;639 };640 $this->given($sqsAdapter)641 ->array($sqsAdapter->listQueues())->containsValues(['testQueueOne', 'prefixTestQueueOne', 'prefixTestQueueTwo']);642 }643 public function testSQSAdapterRenameQueueWithEmptySourceQueueName()644 {645 $this->mockGenerator->orphanize('__construct');646 $this->mockGenerator->shuntParentClassCalls();647 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;648 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);649 $this->exception(function() use($sqsAdapter) {650 $sqsAdapter->renameQueue('', 'targetQueue');651 });652 }653 public function testSQSAdapterRenameQueueWithEmptyTargetQueueName()654 {655 $this->mockGenerator->orphanize('__construct');656 $this->mockGenerator->shuntParentClassCalls();657 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;658 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);659 $this->exception(function() use($sqsAdapter) {660 $sqsAdapter->renameQueue('sourceQueue', '');661 });662 }663 public function testSQSAdapterRenameQueue()664 {665 $this->mockGenerator->orphanize('__construct');666 $this->mockGenerator->shuntParentClassCalls();667 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;668 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;669 $priorityHandler = new ThreeLevelPriorityHandler();670 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);671 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {672 return $mockQueueUrlModel;673 };674 $mockSqsClient->getMockController()->listQueues = function () use($mockQueueUrlModel) {675 return $mockQueueUrlModel;676 };677 $mockSqsClient->getMockController()->sendMessage = function () use($mockQueueUrlModel) {678 };679 $mockQueueUrlModel->getMockController()->get = function ($attr) use($mockQueueUrlModel, $priorityHandler) {680 if ($attr === 'Messages')681 {682 static $i = true;683 if ($i) {684 $i = false;685 return [['priority' => $priorityHandler->getHighest(), 'ReceiptHandle' => 'testReceiptHandle', 'Body' => serialize('test message one')], ['priority' => $priorityHandler->getHighest(), 'ReceiptHandle' => 'testReceiptHandle', 'Body' => serialize('test message two')]];686 } else {687 $i = true;688 return [];689 }690 }691 return null;692 };693 $mockSqsClient->getMockController()->receiveMessage = function () use($mockQueueUrlModel) {694 return $mockQueueUrlModel;695 };696 $mockSqsClient->getMockController()->deleteMessage = function () use($mockQueueUrlModel) {697 };698 $mockSqsClient->getMockController()->createQueue = function () use($mockQueueUrlModel) {699 };700 $mockSqsClient->getMockController()->deleteQueue = function () use($mockQueueUrlModel) {701 };702 $this->given($sqsAdapter)703 ->class($sqsAdapter->renameQueue('sourceQueue', 'targetQueue'))->hasInterface('\ReputationVIP\QueueClient\Adapter\AdapterInterface');704 }705 public function testSQSAdapterGetPrioritiesHandler()706 {707 $this->mockGenerator->orphanize('__construct');708 $this->mockGenerator->shuntParentClassCalls();709 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;710 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;711 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient);712 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {713 return $mockQueueUrlModel;714 };715 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {716 return null;717 };718 $mockSqsClient->getMockController()->purgeQueue = function () use($mockQueueUrlModel) {719 return $mockQueueUrlModel;720 };721 $this->given($sqsAdapter)722 ->class($sqsAdapter->getPriorityHandler())->hasInterface('\ReputationVIP\QueueClient\PriorityHandler\PriorityHandlerInterface');723 }724 public function testMalformedMessageException()725 {726 $this->mockGenerator->orphanize('__construct');727 $this->mockGenerator->shuntParentClassCalls();728 $mockSqsClient = new \mock\Aws\Sqs\SqsClient;729 $mockQueueUrlModel = new \mock\Guzzle\Service\Resource\Model;730 $priorityHandler = new ThreeLevelPriorityHandler();731 $sqsAdapter = new \ReputationVIP\QueueClient\Adapter\SQSAdapter($mockSqsClient, $priorityHandler);732 $mockSqsClient->getMockController()->getQueueUrl = function () use($mockQueueUrlModel) {733 return $mockQueueUrlModel;734 };735 $mockQueueUrlModel->getMockController()->get = function () use($mockQueueUrlModel) {736 return [['Body' => 'test message one']];737 };738 $mockSqsClient->getMockController()->receiveMessage = function () use($mockQueueUrlModel) {739 return $mockQueueUrlModel;740 };741 $this->exception(function() use($sqsAdapter) {...

Full Screen

Full Screen

Event.php

Source:Event.php Github

copy

Full Screen

...7{8 public function testConstruct()9 {10 $this11 ->if($this->mockGenerator->shuntParentClassCalls())12 ->and($request = new \mock\Philip\IRC\Request($raw = uniqid()))13 ->then14 ->object($object = new TestedClass($request))->isInstanceOf('\\Philip\\IRC\\Event')15 ->array($object->getMatches())->isEmpty()16 ->array($object->getResponses())->isEmpty()17 ;18 }19 public function testSetMatches()20 {21 $this22 ->if($this->mockGenerator->shuntParentClassCalls())23 ->and($request = new \mock\Philip\IRC\Request($raw = uniqid()))24 ->and($object = new TestedClass($request))25 ->and($matches = array(uniqid(), uniqid()))26 ->then27 ->object($object->setMatches($matches))->isIdenticalTo($object)28 ->array($object->getMatches())->isEqualTo($matches)29 ;30 }31 public function testGetMatches()32 {33 $this34 ->if($this->mockGenerator->shuntParentClassCalls())35 ->and($request = new \mock\Philip\IRC\Request($raw = uniqid()))36 ->and($object = new TestedClass($request))37 ->and($matches = array(uniqid(), uniqid()))38 ->then39 ->array($object->getMatches())->isEqualTo(array())40 ->if($object->setMatches($matches))41 ->then42 ->array($object->getMatches())->isEqualTo($matches)43 ;44 }45 public function testGetRequest()46 {47 $this48 ->if($this->mockGenerator->shuntParentClassCalls())49 ->and($request = new \mock\Philip\IRC\Request($raw = uniqid()))50 ->and($object = new TestedClass($request))51 ->then52 ->object($object->getRequest())->isIdenticalTo($request)53 ;54 }55 public function testAddResponse()56 {57 $this58 ->if($this->mockGenerator->shuntParentClassCalls())59 ->and($request = new \mock\Philip\IRC\Request($raw = uniqid()))60 ->and($response = new \Philip\IRC\Response(uniqid()))61 ->and($object = new TestedClass($request))62 ->then63 ->object($object->addResponse($response))->isIdenticalTo($object)64 ->array($object->getResponses())->isEqualTo(array($response))65 ->if($otherResponse = new \Philip\IRC\Response(uniqid()))66 ->and($object->addResponse($otherResponse))67 ->then68 ->array($object->getResponses())->isEqualTo(array($response, $otherResponse))69 ;70 }71 public function testGetResponses()72 {73 $this74 ->if($this->mockGenerator->shuntParentClassCalls())75 ->and($request = new \mock\Philip\IRC\Request($raw = uniqid()))76 ->and($object = new TestedClass($request))77 ->and($matches = array(uniqid(), uniqid()))78 ->then79 ->array($object->getResponses())->isEmpty()80 ->if($response = new \Philip\IRC\Response(uniqid()))81 ->and($object->addResponse($response))82 ->then83 ->array($object->getResponses())->isEqualTo(array($response))84 ->if($otherResponse = new \Philip\IRC\Response(uniqid()))85 ->and($object->addResponse($otherResponse))86 ->then87 ->array($object->getResponses())->isEqualTo(array($response, $otherResponse))88 ;...

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1require_once 'generator.php';2$generator = new Generator();3$generator->shuntParentClassCalls();4require_once 'generator.php';5$generator = new Generator();6$generator->shuntParentClassCalls();7require_once 'generator.php';8$generator = new Generator();9$generator->shuntParentClassCalls();10require_once 'generator.php';11$generator = new Generator();12$generator->shuntParentClassCalls();13require_once 'generator.php';14$generator = new Generator();15$generator->shuntParentClassCalls();16require_once 'generator.php';17$generator = new Generator();18$generator->shuntParentClassCalls();19require_once 'generator.php';20$generator = new Generator();21$generator->shuntParentClassCalls();22require_once 'generator.php';23$generator = new Generator();24$generator->shuntParentClassCalls();25require_once 'generator.php';26$generator = new Generator();27$generator->shuntParentClassCalls();28require_once 'generator.php';29$generator = new Generator();30$generator->shuntParentClassCalls();31require_once 'generator.php';32$generator = new Generator();33$generator->shuntParentClassCalls();34require_once 'generator.php';35$generator = new Generator();36$generator->shuntParentClassCalls();

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1require_once 'Zend/CodeGenerator/Php/Class.php';2$generator = new Zend_CodeGenerator_Php_Class();3$generator->setName('MyClass');4$generator->setExtendedClass('Zend_Db_Table_Abstract');5$generator->setMethod(array('name' => 'init', 'body' => 'parent::init();'));6$generator->setMethod(array('name' => 'save', 'body' => 'parent::save();'));7$generator->setMethod(array('name' => 'delete', 'body' => 'parent::delete();'));8$generator->setMethod(array('name' => 'find', 'body' => 'parent::find();'));9$generator->setMethod(array('name' => 'fetchAll', 'body' => 'parent::fetchAll();'));10$generator->setMethod(array('name' => 'fetchRow', 'body' => 'parent::fetchRow();'));11$generator->setMethod(array('name' => 'getAdapter', 'body' => 'parent::getAdapter();'));12$generator->setMethod(array('name' => 'getTableName', 'body' => 'parent::getTableName();'));13$generator->setMethod(array('name' => 'getPrimaryKey', 'body' => 'parent::getPrimaryKey();'));14$generator->setMethod(array('name' => 'getSequenceId', 'body' => 'parent::getSequenceId();'));15$generator->setMethod(array('name' => 'setDefaultAdapter', 'body' => 'parent::setDefaultAdapter();'));16$generator->setMethod(array('name' => 'setDefaultMetadataCache', 'body' => 'parent::setDefaultMetadataCache();'));17$generator->setMethod(array('name' => 'setMetadataCache', 'body' => 'parent::setMetadataCache();'));18$generator->setMethod(array('name' => 'getMetadataCache', 'body' => 'parent::getMetadataCache();'));19$generator->setMethod(array('name' => 'getAdapterName', 'body' => 'parent::getAdapterName();'));20$generator->setMethod(array('name' => 'setAdapterName', 'body' => 'parent::setAdapterName();'));21$generator->setMethod(array('name' => 'getSchemaName', 'body' => 'parent::getSchemaName();'));22$generator->setMethod(array('name' => 'setSchemaName', 'body' => 'parent::setSchemaName

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1require_once 'generator.php';2$generator = new generator();3$generator->shuntParentClassCalls('1.php');4require_once 'generator.php';5$generator = new generator();6$generator->shuntParentClassCalls('2.php');7require_once 'generator.php';8$generator = new generator();9$generator->shuntParentClassCalls('3.php');10require_once 'generator.php';11$generator = new generator();12$generator->shuntParentClassCalls('4.php');13require_once 'generator.php';14$generator = new generator();15$generator->shuntParentClassCalls('5.php');16require_once 'generator.php';17$generator = new generator();18$generator->shuntParentClassCalls('6.php');19require_once 'generator.php';20$generator = new generator();21$generator->shuntParentClassCalls('7.php');22require_once 'generator.php';23$generator = new generator();24$generator->shuntParentClassCalls('8.php');25require_once 'generator.php';26$generator = new generator();27$generator->shuntParentClassCalls('9.php');28require_once 'generator.php';29$generator = new generator();30$generator->shuntParentClassCalls('10.php');31require_once 'generator.php';32$generator = new generator();33$generator->shuntParentClassCalls('11.php');

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1$generator->shuntParentClassCalls();2$generator->unshuntParentClassCalls();3$generator->shuntParentClassCalls();4$generator->unshuntParentClassCalls();5$generator->shuntParentClassCalls();6$generator->unshuntParentClassCalls();7$generator->shuntParentClassCalls();8$generator->unshuntParentClassCalls();9$generator->shuntParentClassCalls();10$generator->unshuntParentClassCalls();11$generator->shuntParentClassCalls();12$generator->unshuntParentClassCalls();13In the above example, the shuntParentClassCalls() method is called 6 times and the unshuntParentClassCalls() method

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1$generator = new Generator();2$generator->shuntParentClassCalls();3$generator = new Generator();4$generator->shuntParentClassCalls();5$generator = new Generator();6$generator->shuntParentClassCalls();7$generator = new Generator();8$generator->shuntParentClassCalls();9$generator = new Generator();10$generator->shuntParentClassCalls();11$generator = new Generator();12$generator->shuntParentClassCalls();13$generator = new Generator();14$generator->shuntParentClassCalls();15$generator = new Generator();16$generator->shuntParentClassCalls();17$generator = new Generator();18$generator->shuntParentClassCalls();19$generator = new Generator();20$generator->shuntParentClassCalls();21$generator = new Generator();22$generator->shuntParentClassCalls();23$generator = new Generator();24$generator->shuntParentClassCalls();

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1$generator = new Generator();2$generator->shuntParentClassCalls();3$generator->fromFile('1.php');4$generator->parseCode();5$generator->save('2.php');6$generator = new Generator();7$generator->shuntParentClassCalls();8$generator->fromFile('2.php');9$generator->parseCode();10$generator->save('3.php');11$generator = new Generator();12$generator->shuntParentClassCalls();13$generator->fromFile('3.php');14$generator->parseCode();15$generator->save('4.php');16$generator = new Generator();17$generator->shuntParentClassCalls();18$generator->fromFile('4.php');19$generator->parseCode();20$generator->save('5.php');21$generator = new Generator();22$generator->shuntParentClassCalls();23$generator->fromFile('5.php');24$generator->parseCode();25$generator->save('6.php');26$generator = new Generator();27$generator->shuntParentClassCalls();28$generator->fromFile('6.php');29$generator->parseCode();30$generator->save('7.php');31$generator = new Generator();32$generator->shuntParentClassCalls();33$generator->fromFile('7.php');34$generator->parseCode();35$generator->save('8.php');36$generator = new Generator();37$generator->shuntParentClassCalls();38$generator->fromFile('8.php');39$generator->parseCode();40$generator->save('9.php');41$generator = new Generator();42$generator->shuntParentClassCalls();43$generator->fromFile('9.php');

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1require_once 'generator.php';2$gen = new Generator();3$gen->shuntParentClassCalls($className, $methodName, $args);4require_once 'generator.php';5$gen = new Generator();6$gen->shuntParentClassCalls($className, $methodName, $args);7require_once 'generator.php';8$gen = new Generator();9$gen->shuntParentClassCalls($className, $methodName, $args);10require_once 'generator.php';11$gen = new Generator();12$gen->shuntParentClassCalls($className, $methodName, $args);13require_once 'generator.php';14$gen = new Generator();15$gen->shuntParentClassCalls($className, $methodName, $args);16require_once 'generator.php';17$gen = new Generator();18$gen->shuntParentClassCalls($className, $methodName, $args);19require_once 'generator.php';20$gen = new Generator();21$gen->shuntParentClassCalls($className, $methodName, $args);22require_once 'generator.php';23$gen = new Generator();24$gen->shuntParentClassCalls($className, $methodName, $args);25require_once 'generator.php';26$gen = new Generator();27$gen->shuntParentClassCalls($className, $methodName, $args);28require_once 'generator.php';29$gen = new Generator();

Full Screen

Full Screen

shuntParentClassCalls

Using AI Code Generation

copy

Full Screen

1$gen->shuntParentClassCalls($className, $parentClassName);2{3 public function __construct()4 {5 parent::__construct();6 }7 public function __destruct()8 {9 parent::__destruct();10 }11 public function method1()12 {13 parent::method1();14 }15 public function method2()16 {17 parent::method2();18 }19 public function method3()20 {21 parent::method3();22 }23 public function method4()24 {25 parent::method4();26 }27 public function method5()28 {29 parent::method5();30 }31 public function method6()32 {33 parent::method6();34 }35 public function method7()36 {37 parent::method7();38 }39 public function method8()40 {41 parent::method8();42 }43 public function method9()44 {45 parent::method9();46 }47 public function method10()48 {49 parent::method10();50 }51 public function method11()52 {53 parent::method11();54 }55 public function method12()56 {57 parent::method12();58 }59 public function method13()60 {61 parent::method13();62 }63 public function method14()64 {65 parent::method14();66 }67 public function method15()68 {69 parent::method15();70 }71 public function method16()72 {73 parent::method16();74 }75 public function method17()76 {77 parent::method17();78 }79 public function method18()80 {81 parent::method18();82 }83 public function method19()84 {85 parent::method19();86 }87 public function method20()88 {89 parent::method20();90 }91 public function method21()92 {93 parent::method21();94 }95 public function method22()96 {97 parent::method22();98 }99 public function method23()100 {101 parent::method23();102 }103 public function method24()104 {105 parent::method24();106 }107 public function method25()108 {109 parent::method25();110 }111 public function method26()112 {113 parent::method26();114 }115 public function method27()

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in generator

Trigger shuntParentClassCalls code on LambdaTest Cloud Grid

Execute automation tests with shuntParentClassCalls on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful