From 278e6f6e345b0bc067a41d6173a38ea789df2572 Mon Sep 17 00:00:00 2001 From: Cretu Eusebiu Date: Fri, 8 Jan 2021 17:06:49 +0200 Subject: [PATCH] Remove empty icon Closes #130 --- src/WebPushMessage.php | 2 +- tests/MessageTest.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/WebPushMessage.php b/src/WebPushMessage.php index 891b70b..2e6e2c5 100644 --- a/src/WebPushMessage.php +++ b/src/WebPushMessage.php @@ -102,7 +102,7 @@ public function title($value) */ public function action($title, $action, $icon = null) { - $this->actions[] = compact('title', 'action', 'icon'); + $this->actions[] = array_filter(compact('title', 'action', 'icon')); return $this; } diff --git a/tests/MessageTest.php b/tests/MessageTest.php index bfbff71..8673f4e 100644 --- a/tests/MessageTest.php +++ b/tests/MessageTest.php @@ -27,6 +27,16 @@ public function title_can_be_set() /** @test */ public function action_can_be_set() + { + $this->message->action('Some Action', 'some_action'); + + $this->assertEquals( + [['title' => 'Some Action', 'action' => 'some_action']], $this->message->toArray()['actions'] + ); + } + + /** @test */ + public function action_can_be_set_with_icon() { $this->message->action('Some Action', 'some_action', '/icon.png');