From b87b3d1dd899faebf152f2eff9d8db79dd8a898f Mon Sep 17 00:00:00 2001 From: Ronny Herrgesell Date: Thu, 30 Nov 2023 15:57:31 +0100 Subject: [PATCH] EA-5554: Bug fix for responders --- src/Alert/CreateAlertRequest.php | 2 +- tests/Alert/CreateAlertRequestTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Alert/CreateAlertRequest.php b/src/Alert/CreateAlertRequest.php index 1937fe7..e62dd41 100644 --- a/src/Alert/CreateAlertRequest.php +++ b/src/Alert/CreateAlertRequest.php @@ -59,7 +59,7 @@ public function getBody(): array } foreach ($this->alert->getResponders() as $responder) { - $body['responders'] = [ + $body['responders'][] = [ 'id' => $responder->getId(), 'type' => $responder->getType() ]; diff --git a/tests/Alert/CreateAlertRequestTest.php b/tests/Alert/CreateAlertRequestTest.php index f7d77a2..e14813f 100644 --- a/tests/Alert/CreateAlertRequestTest.php +++ b/tests/Alert/CreateAlertRequestTest.php @@ -38,12 +38,14 @@ public function testCanAppendResponder(): void { $alert = $this->createMock(Alert::class); $alert->expects($this->atLeastOnce())->method('getResponders')->willReturn([ - $this->createMock(Responder::class), - $this->createMock(Responder::class) + new Responder('foo', Responder::team), + new Responder('bar', Responder::user), ]); $request = new CreateAlertRequest($alert); $this->assertArrayHasKey('responders', $request->getBody()); + $this->assertEquals(['id' => 'foo', 'type' => 'team'], $request->getBody()['responders'][0]); + $this->assertEquals(['id' => 'bar', 'type' => 'user'], $request->getBody()['responders'][1]); } public function testCanAppendTags(): void