From 275cee0b04d864eb0830fbff95ae78f773f0e0b3 Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Mon, 28 Oct 2024 08:18:17 +0200 Subject: [PATCH 1/2] UHF-10844: Add raven monolog logger https://git.drupalcode.org/project/raven\#monolog-module-integration --- src/HelfiApiBaseServiceProvider.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/HelfiApiBaseServiceProvider.php b/src/HelfiApiBaseServiceProvider.php index 8957b59..43741b1 100644 --- a/src/HelfiApiBaseServiceProvider.php +++ b/src/HelfiApiBaseServiceProvider.php @@ -37,6 +37,10 @@ public function register(ContainerBuilder $container) : void { 'name' => 'default_conditional_handler', 'formatter' => 'drush_or_json', ], + [ + 'name' => 'drupal.raven', + 'processors' => ['current_user', 'request_uri', 'ip', 'referer'], + ], ], ], ]); From 74e1c338ad6ba7baf173bb505de56ced34ea702d Mon Sep 17 00:00:00 2001 From: Santeri Hurnanen Date: Mon, 28 Oct 2024 10:49:42 +0200 Subject: [PATCH 2/2] UHF-10844: Fix tests --- tests/src/Unit/Commands/PubSubCommandsTest.php | 8 ++++---- tests/src/Unit/Commands/RevisionCommandsTest.php | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/src/Unit/Commands/PubSubCommandsTest.php b/tests/src/Unit/Commands/PubSubCommandsTest.php index 03ccb34..697a042 100644 --- a/tests/src/Unit/Commands/PubSubCommandsTest.php +++ b/tests/src/Unit/Commands/PubSubCommandsTest.php @@ -8,11 +8,11 @@ use Drupal\helfi_api_base\Azure\PubSub\PubSubManagerInterface; use Drupal\helfi_api_base\Drush\Commands\PubSubCommands; use Drush\Commands\DrushCommands; +use Drush\Style\DrushStyle; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; use WebSocket\ConnectionException; use WebSocket\TimeoutException; @@ -31,7 +31,7 @@ public function testListen() : void { $expectedMessage = '{"message":"test"}'; $output = $this->prophesize(OutputInterface::class); $input = $this->prophesize(InputInterface::class); - $io = $this->prophesize(SymfonyStyle::class); + $io = $this->prophesize(DrushStyle::class); $io->writeln(Argument::containingString('Received message')) ->shouldBeCalledTimes(PubSubCommands::MAX_MESSAGES); $io->writeln(Argument::containingString('Received maximum number of messages')) @@ -51,7 +51,7 @@ public function testListen() : void { public function testExceptionOutput() : void { $output = $this->prophesize(OutputInterface::class); $input = $this->prophesize(InputInterface::class); - $io = $this->prophesize(SymfonyStyle::class); + $io = $this->prophesize(DrushStyle::class); $io->writeln('Invalid json: Syntax error')->shouldBeCalledTimes(PubSubCommands::MAX_MESSAGES); $io->writeln(Argument::containingString('Received maximum number of messages')) ->shouldBeCalledTimes(1); @@ -70,7 +70,7 @@ public function testExceptionOutput() : void { public function testTimeoutException() : void { $output = $this->prophesize(OutputInterface::class); $input = $this->prophesize(InputInterface::class); - $io = $this->prophesize(SymfonyStyle::class); + $io = $this->prophesize(DrushStyle::class); $io->writeln(Argument::containingString('Received maximum number of messages')) ->shouldBeCalledTimes(1); diff --git a/tests/src/Unit/Commands/RevisionCommandsTest.php b/tests/src/Unit/Commands/RevisionCommandsTest.php index 335fa60..ad7a133 100644 --- a/tests/src/Unit/Commands/RevisionCommandsTest.php +++ b/tests/src/Unit/Commands/RevisionCommandsTest.php @@ -13,12 +13,12 @@ use Drupal\helfi_api_base\Commands\RevisionCommands; use Drupal\helfi_api_base\Entity\Revision\RevisionManager; use Drush\Commands\DrushCommands; +use Drush\Style\DrushStyle; use Prophecy\Argument; use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; /** * Tests revision commands. @@ -114,7 +114,7 @@ private function getConnectionMock(array $expected, ?int $id = NULL) : Connectio * Test command with invalid entity type. */ public function testInvalidEntityType() : void { - $io = $this->prophesize(SymfonyStyle::class); + $io = $this->prophesize(DrushStyle::class); $io->writeln(Argument::containingString('Given entity type is not supported.')) ->shouldBeCalled(); @@ -130,7 +130,7 @@ public function testInvalidEntityType() : void { * Test delete without any entities. */ public function testNoEntities() : void { - $io = $this->prophesize(SymfonyStyle::class); + $io = $this->prophesize(DrushStyle::class); $io->isDecorated() ->willReturn(TRUE); $io->getVerbosity() @@ -148,7 +148,7 @@ public function testNoEntities() : void { * Tests delete method with proper data. */ public function testDelete() : void { - $io = $this->prophesize(SymfonyStyle::class); + $io = $this->prophesize(DrushStyle::class); $io->isDecorated() ->willReturn(TRUE); $io->getVerbosity() @@ -170,7 +170,7 @@ public function testDelete() : void { * Tests delete method with optional ID. */ public function testDeleteWithId() : void { - $io = $this->prophesize(SymfonyStyle::class); + $io = $this->prophesize(DrushStyle::class); $io->isDecorated() ->willReturn(TRUE); $io->getVerbosity()