Skip to content

Commit f8cd4fe

Browse files
committed
chore(test): add integration test for Users::executeActionsEmail()
1 parent c6bcf30 commit f8cd4fe

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

src/Http/CommandExecutor.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function executeCommand(Command $command): void
2525
'body' => $this->serializer->serialize($command->getPayload()),
2626
'headers' => [
2727
'Content-Type' => $command->getContentType()->value,
28-
]
28+
],
2929
],
3030
ContentType::FORM_PARAMS => ['form_params' => $command->getPayload()],
3131
};

tests/Integration/Resource/UsersTest.php

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Fschmtt\Keycloak\Representation\Role;
1414
use Fschmtt\Keycloak\Representation\User;
1515
use Fschmtt\Keycloak\Test\Integration\IntegrationTestBehaviour;
16+
use GuzzleHttp\Exception\ServerException;
1617
use PHPUnit\Framework\TestCase;
1718
use Ramsey\Uuid\Uuid;
1819

@@ -195,13 +196,20 @@ public function testExecuteActionsEmail(): void
195196
$username = Uuid::uuid4()->toString();
196197

197198
$users->create('master', new User(
199+
200+
enabled: true,
198201
username: $username,
199202
));
200203

201204
$user = $this->searchUserByUsername($username);
202205
static::assertInstanceOf(User::class, $user);
203206

204-
$users->executeActionsEmail('master', $user->getId(), ['UPDATE_PASSWORD']);
207+
try {
208+
$users->executeActionsEmail('master', $user->getId(), ['UPDATE_PASSWORD']);
209+
} catch (ServerException $e) {
210+
static::assertSame(500, $e->getResponse()->getStatusCode());
211+
static::assertStringContainsString('Failed to send execute actions email', $e->getResponse()->getBody()->getContents());
212+
}
205213

206214
$users->delete('master', $user->getId());
207215

tests/Unit/Http/CommandExecutorTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testCallsClientWithoutBodyIfCommandHasNoRepresentation(): void
3131
'body' => null,
3232
'headers' => [
3333
'Content-Type' => 'application/json',
34-
]
34+
],
3535
],
3636
);
3737

0 commit comments

Comments
 (0)