Skip to content

Commit

Permalink
Merge pull request #2 from rjvandoesburg/fix-message_format
Browse files Browse the repository at this point in the history
Fix setting of message_format
  • Loading branch information
mpociot authored Feb 20, 2018
2 parents 312c0e0 + 8dc7153 commit 6d7cb3f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/HipChatDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function isBot()
*/
public function buildServicePayload($message, $matchingMessage, $additionalParameters = [])
{
$parameters = array_merge_recursive([
$parameters = array_replace_recursive([
'message_format' => 'text',
], $additionalParameters);
/*
Expand Down
31 changes: 31 additions & 0 deletions tests/HipChatDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,35 @@ public function it_is_configured()

$this->assertFalse($driver->isConfigured());
}

/** @test */
public function it_builds_the_correct_payload()
{
// Given a user wants to send html
$driver = $this->getDriver([
'event' => 'room_message',
'item' => [
'message' => [
'from' => [
'id' => '12345',
],
'message' => 'Hi Julia',
],
'room' => [
'id' => '98765',
],
],
'webhook_id' => '11223344',
]);
$message = $driver->getMessages()[0];
$payload = $driver->buildServicePayload('Test message', $message);
$this->assertEquals('text', $payload['message_format']);

// Now if the user wants to set the format to HTML
$payload = $driver->buildServicePayload('Test message', $message, [
'message_format' => 'html',
]);

$this->assertEquals('html', $payload['message_format']);
}
}

0 comments on commit 6d7cb3f

Please sign in to comment.