From ada4a243a948a977f54d92c0e3a98cc56af39104 Mon Sep 17 00:00:00 2001 From: Roel van Duijnhoven Date: Fri, 9 Jul 2021 13:07:43 +0200 Subject: [PATCH] Drop Laminas Console, as it is deprecated and does not function on PHP8. And really it is only used by SlmQueue/Doctrine. --- src/Controller/AbstractWorkerController.php | 64 --------------- tests/Asset/SimpleController.php | 12 --- tests/Controller/AbstractControllerTest.php | 86 --------------------- 3 files changed, 162 deletions(-) delete mode 100644 src/Controller/AbstractWorkerController.php delete mode 100644 tests/Asset/SimpleController.php delete mode 100644 tests/Controller/AbstractControllerTest.php diff --git a/src/Controller/AbstractWorkerController.php b/src/Controller/AbstractWorkerController.php deleted file mode 100644 index ddd6daa..0000000 --- a/src/Controller/AbstractWorkerController.php +++ /dev/null @@ -1,64 +0,0 @@ -worker = $worker; - $this->queuePluginManager = $queuePluginManager; - } - - public function processAction(): string - { - $options = $this->params()->fromRoute(); - $name = $options['queue']; - $queue = $this->queuePluginManager->get($name); - - try { - $messages = $this->worker->processQueue($queue, $options); - } catch (ExceptionInterface $e) { - throw new WorkerProcessException( - 'Caught exception while processing queue', - $e->getCode(), - $e - ); - } - - return $this->formatOutput($name, $messages); - } - - protected function formatOutput(string $queueName, array $messages = []): string - { - $messages = implode("\n", array_map(function (string $message): string { - return sprintf(' - %s', $message); - }, $messages)); - - return sprintf( - "Finished worker for queue '%s':\n%s\n", - $queueName, - $messages - ); - } -} diff --git a/tests/Asset/SimpleController.php b/tests/Asset/SimpleController.php deleted file mode 100644 index bc95ccb..0000000 --- a/tests/Asset/SimpleController.php +++ /dev/null @@ -1,12 +0,0 @@ -getEventManager(); - (new ProcessQueueStrategy())->attach($eventManager); - (new MaxRunsStrategy(['max_runs' => 1]))->attach($eventManager); - $serviceManager = new ServiceManager(); - $config = [ - 'factories' => [ - 'knownQueue' => SimpleQueueFactory::class, - ], - ]; - - $this->queuePluginManager = new QueuePluginManager($serviceManager, $config); - $this->controller = new SimpleController($worker, $this->queuePluginManager); - } - - public function testThrowExceptionIfQueueIsUnknown(): void - { - $routeMatch = new RouteMatch(['queue' => 'unknownQueue']); - $this->controller->getEvent()->setRouteMatch($routeMatch); - - $this->expectException(ServiceNotFoundException::class); - $this->controller->processAction(); - } - - public function testSimpleJob(): void - { - /** @var SimpleQueue $queue */ - $queue = $this->queuePluginManager->get('knownQueue'); - $queue->push(new SimpleJob()); - - $routeMatch = new RouteMatch(['queue' => 'knownQueue']); - $this->controller->getEvent()->setRouteMatch($routeMatch); - - $result = $this->controller->processAction(); - static::assertStringContainsString("Finished worker for queue 'knownQueue'", $result); - static::assertStringContainsString("maximum of 1 jobs processed", $result); - } - - public function testFailingJobThrowException(): void - { - /** @var SimpleQueue $queue */ - $queue = $this->queuePluginManager->get('knownQueue'); - $queue->push(new FailingJob()); - - $routeMatch = new RouteMatch(['queue' => 'knownQueue']); - $this->controller->getEvent()->setRouteMatch($routeMatch); - - $this->expectException(WorkerProcessException::class); - $this->controller->processAction(); - } -}