How to use getMockController method of generator class

Best Atoum code snippet using generator.getMockController

FileAdapter.php

Source:FileAdapter.php Github

copy

Full Screen

...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;...

Full Screen

Full Screen

Apns.php

Source:Apns.php Github

copy

Full Screen

...96 ->and($this->mockGenerator()->orphanize('__construct'))97 ->and($this->mockGenerator()->orphanize('open'))98 ->and($this->mockClass(ZendClientMessage::class, '\Mock\ZendService'))99 ->and($serviceClient = new \Mock\ZendService\Message())100 ->and($object->getMockController()->getParameters = [])101 ->exception(static function () use ($object) {102 $object->getOpenedClient(new ZendClientMessage());103 })104 ->isInstanceOf(InvalidArgumentException::class)105 ->message106 ->contains('Certificate must be a valid path to a APNS certificate')107 ->when($object = new TestedModel(['certificate' => __DIR__ . '/../Resources/apns-certificate.pem']))108 ->and($object->getOpenedClient($serviceClient));109 }110 public function testGetServiceMessageFromOrigin()111 {112 $this->if($this->mockGenerator()->orphanize('__construct'))113 ->and($this->mockClass(TestedModel::class, '\Mock'))114 ->and($object = new \Mock\Apns())115 ->and($this->mockGenerator()->orphanize('__construct'))116 ->and($this->mockClass(Device::class, '\Mock'))117 ->and($device = new \Mock\Device())118 ->and($device->getMockController()->getToken = self::APNS_TOKEN_EXAMPLE_64)119 ->and($this->mockGenerator()->orphanize('__construct'))120 ->and($this->mockClass(Message::class, '\Mock'))121 ->and($message = new \Mock\Message())122 ->and($message->getMockController()->getText = 'Test')123 ->object($object->getServiceMessageFromOrigin($device, $message))124 ->isInstanceOf(ZendServiceMessage::class);125 }126 public function testPush()127 {128 $this->if($this->mockGenerator()->orphanize('__construct')129 ->makeVisible('getOpenedServiceClient')130 ->generate(TestedModel::class, '\Mock', 'Apns'))131 ->and($object = new \Mock\Apns())132 ->and($object->setResponse(new Response()))133 ->and($this->mockClass(ZendResponseMessage::class, '\Mock\ZendService', 'Response'))134 ->and($serviceResponse = new \Mock\ZendService\Response())135 ->and($serviceResponse->getMockController()->getCode = ZendResponseMessage::RESULT_OK)136 ->and($serviceResponse->getMockController()->getId = 0)137 ->and($this->mockGenerator()->orphanize('__construct')138 ->orphanize('open')139 ->orphanize('send')140 ->generate(ZendClientMessage::class, '\Mock\ZendService'))141 ->and($serviceClient = new \Mock\ZendService\Message())142 ->and($serviceClient->getMockController()->send = $serviceResponse)143 ->and($this->mockGenerator()->orphanize('__construct'))144 ->and($this->mockClass(Push::class, '\Mock'))145 ->and($push = new \Mock\Push())146 ->and($push->getMockController()->getMessage = new Message('Test'))147 ->and($push->getMockController()->getDevices = new DeviceCollection(148 [new Device(self::APNS_TOKEN_EXAMPLE_64)]149 ))150 ->and($object->getMockController()->getServiceMessageFromOrigin = new ZendServiceMessage())151 ->and($object->getMockController()->getOpenedClient = $serviceClient)152 ->and($this->calling($object)->getOpenedServiceClient = $serviceClient)153 ->object($result = $object->push($push))154 ->isInstanceOf(DeviceCollection::class)155 ->boolean($result->count() == 1)156 ->isTrue();157 }158 public function testCountIsEmpty()159 {160 $this->if($dcoll = new DeviceCollection())161 ->boolean($dcoll->isEmpty())162 ->isTrue();163 }164 public function testFeedback()165 {166 $this->if($this->mockGenerator()->orphanize('__construct'))167 ->and($this->mockClass(TestedModel::class, '\Mock'))168 ->and($object = new \Mock\Apns())169 ->and($this->mockClass(ZendResponseMessage::class, '\Mock\ZendService', 'Response'))170 ->and($serviceResponse = new \Mock\ZendService\Response())171 ->and($this->mockGenerator()->orphanize('__construct'))172 ->and($this->mockGenerator()->orphanize('open'))173 ->and($this->mockGenerator()->orphanize('send'))174 ->and($this->mockClass(Feedback::class, '\Mock\ZendService'))175 ->and($serviceClient = new \Mock\ZendService\Feedback())176 ->and($serviceClient->getMockController()->feedback = $serviceResponse)177 ->and($object->getMockController()->getServiceMessageFromOrigin = new ZendServiceMessage())178 ->and($object->getMockController()->getOpenedClient = $serviceClient)179 ->array($object->getFeedback())180 ->isEmpty();181 }182}...

Full Screen

Full Screen

getMockController

Using AI Code Generation

copy

Full Screen

1$controller = $this->getMockController('controller_name');2$controller->expects($this->any())3->method('method_name')4->will($this->returnValue('return_value'));5$model = $this->getMockModel('model_name');6$model->expects($this->any())7->method('method_name')8->will($this->returnValue('return_value'));9$view = $this->getMockView('view_name');10$view->expects($this->any())11->method('method_name')12->will($this->returnValue('return_value'));13$component = $this->getMockComponent('component_name');14$component->expects($this->any())15->method('method_name')16->will($this->returnValue('return_value'));17$helper = $this->getMockHelper('helper_name');18$helper->expects($this->any())19->method('method_name')20->will($this->returnValue('return_value'));21$behavior = $this->getMockBehavior('behavior_name');22$behavior->expects($this->any())23->method('method_name')24->will($this->returnValue('return_value'));25$shell = $this->getMockShell('shell_name');26$shell->expects($this->any())27->method('method_name')28->will($this->returnValue('return_value'));29$task = $this->getMockTask('task_name');30$task->expects($this->any())31->method('method_name')32->will($this->returnValue('return_value'));33$controller = $this->getMockController('controller_name');34$controller->expects($this->any())35->method('method_name')36->will($this->returnValue('return_value'));37$model = $this->getMockModel('model_name');38$model->expects($this->any())39->method('method_name')40->will($this->returnValue('return_value'));

Full Screen

Full Screen

getMockController

Using AI Code Generation

copy

Full Screen

1$generator = new Zend_Controller_Action_HelperBroker();2$mockController = $generator->getMockController('index');3$mockController->expects($this->any())4->method('indexAction')5->will($this->returnValue('indexAction'));6$mockController->indexAction();7$generator = new Zend_Controller_Action_HelperBroker();8$mockController = $generator->getMockController('index');9$mockController->expects($this->any())10->method('indexAction')11->will($this->returnValue('indexAction'));12$mockController->indexAction();13OK (1 test, 1 assertion)14$generator = new Zend_Controller_Action_HelperBroker();15$mockController = $generator->getMockController('index');16$mockController->expects($this->any())17->method('indexAction')18->will($this->returnValue('indexAction'));19$mockController->indexAction();20$generator = new Zend_Controller_Action_HelperBroker();21$mockController = $generator->getMockController('index');22$mockController->expects($this->any())23->method('indexAction')24->will($this->returnValue('indexAction'));25$mockController->indexAction();26OK (1 test, 1 assertion)27$generator = new Zend_Controller_Action_HelperBroker();

Full Screen

Full Screen

getMockController

Using AI Code Generation

copy

Full Screen

1$generator = new Generator();2$controller = $generator->getMockController('controllerName');3$controller->methodName->return = 'returnValue';4$generator = new Generator();5$controller = $generator->getMockController('controllerName');6$controller->methodName->return = 'returnValue';7$generator = new Generator();8$controller = $generator->getMockController('controllerName');9$controller->methodName->return = 'returnValue';10$generator = new Generator();11$controller = $generator->getMockController('controllerName');12$controller->methodName->return = 'returnValue';13$generator = new Generator();14$controller = $generator->getMockController('controllerName');15$controller->methodName->return = 'returnValue';16$generator = new Generator();17$controller = $generator->getMockController('controllerName');18$controller->methodName->return = 'returnValue';19$generator = new Generator();20$controller = $generator->getMockController('controllerName');21$controller->methodName->return = 'returnValue';22$generator = new Generator();23$controller = $generator->getMockController('controllerName');24$controller->methodName->return = 'returnValue';25$generator = new Generator();26$controller = $generator->getMockController('controllerName');

Full Screen

Full Screen

getMockController

Using AI Code Generation

copy

Full Screen

1$generator = new Generator();2$controller = $generator->getMockController('controller');3$controller->indexAction = function() {4 return 'Hello World';5};6$generator->run();

Full Screen

Full Screen

getMockController

Using AI Code Generation

copy

Full Screen

1$mockController = $this->getMockController('Controller');2$mockController->expects($this->once())3->method('redirect')4->with('/home/index');5$this->testAction('/home/index', array('method' => 'get'));6}

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 getMockController code on LambdaTest Cloud Grid

Execute automation tests with getMockController 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