Skip to content

Commit

Permalink
Fixing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
challgren committed Jan 5, 2019
1 parent d43d1c5 commit 9f43a45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Mailer/MailgunEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function setTags($tags)
throw new MailgunApiException('You can only set a max of 3 tags.');
}

$this->addHeaders(['X-Mailgun-Tag' => implode(',', $tags)]);
$this->addHeaders(['X-Mailgun-Tag' => json_encode($tags)]);

return $this;
}
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Mailer/MailgunEmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public function tearDown()

public function testTagsArray()
{
$this->Email->setTags(['tag1', 'tag2', 'tag3']);
$tags = ['tag1', 'tag2', 'tag3'];
$this->Email->setTags($tags);
$headers = $this->Email->getHeaders(['X-Mailgun-Tag']);
$expected = 'tag1,tag2,tag3';
$this->assertEquals($expected, $headers['X-Mailgun-Tag']);
$this->assertEquals(json_encode($tags), $headers['X-Mailgun-Tag']);
}

public function testTagsArrayMoreThanThree()
Expand All @@ -54,7 +54,7 @@ public function testTagString()
{
$this->Email->setTags('tag1,tag2,tag3');
$headers = $this->Email->getHeaders(['X-Mailgun-Tag']);
$expected = 'tag1,tag2,tag3';
$expected = json_encode(['tag1', 'tag2', 'tag3']);

$this->assertEquals($expected, $headers['X-Mailgun-Tag']);
}
Expand Down

0 comments on commit 9f43a45

Please sign in to comment.