From 26a4a53eb88da8e19c0d508268925e5db70dc407 Mon Sep 17 00:00:00 2001 From: Pavel Golovin Date: Wed, 21 Feb 2018 14:03:27 +0300 Subject: [PATCH 1/3] Add support for chrome_duration option Add support for chrome_duration option --- .../Pushwoosh/Model/Notification/Chrome.php | 37 +++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php b/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php index 3a3df26..1335867 100644 --- a/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php +++ b/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php @@ -43,6 +43,13 @@ class Chrome implements \JsonSerializable */ private $image; + /** + * Changes chrome push display time. Set to 0 to display push until user interacts with it + * + * @var int + */ + private $duration; + /** * Utility function used to create a new Chrome instance. * @@ -76,7 +83,7 @@ public function getIcon() /** * Gets the header of the message. * - * @var string The header of the message. + * @return string The header of the message. */ public function getTitle() { @@ -86,12 +93,22 @@ public function getTitle() /** * Gets the image of the message. * - * @var string The image of the message. + * @return string The image of the message. */ public function getImage() { return $this->image; } + + /** + * Gets the duration + * + * @return int + */ + public function getDuration() + { + return $this->duration; + } /** * {@inheritdoc} @@ -104,9 +121,9 @@ public function jsonSerialize() isset($this->icon) ? $json['chrome_icon'] = $this->icon : false; isset($this->title) ? $json['chrome_title'] = $this->title : false; isset($this->image) ? $json['chrome_image'] = $this->image : false; + isset($this->duration) ? $json['chrome_duration'] = $this->duration : false; return $json; - } /** @@ -164,4 +181,18 @@ public function setImage($image) return $this; } + + /** + * Sets the duration + * + * @param $duration + * + * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. + */ + public function setDuration($duration) + { + $this->duration = $duration; + + return $this; + } } From 9a9be4dc78a43a142ac06c36513e5d825bf18b4f Mon Sep 17 00:00:00 2001 From: Pavel Golovin Date: Wed, 21 Feb 2018 14:06:56 +0300 Subject: [PATCH 2/3] Add tests for chrome_duration option Add tests for chrome_duration option --- .../Pushwoosh/Model/Notification/ChromeTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php b/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php index 73d41af..c253ed7 100644 --- a/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php +++ b/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php @@ -65,6 +65,16 @@ public function testGetSetImage() $this->assertSame($chrome, $chrome->setImage('Image')); $this->assertSame('Image', $chrome->getImage()); } + + /** + * Test method for the #getDuration() and #setDuration($image) functions. + */ + public function testGetSetDuration() + { + $chrome = new Chrome(); + $this->assertSame($chrome, $chrome->setDuration(120)); + $this->assertSame(120, $chrome->getDuration()); + } /** * Test method for the #jsonSerialize() function. @@ -76,6 +86,7 @@ public function testJsonSerialize() ->setIcon('icon') ->setTitle('Title') ->setImage('Image') + ->setDuration(120) ->jsonSerialize(); $this->assertCount(4, $array); @@ -83,5 +94,6 @@ public function testJsonSerialize() $this->assertSame('icon', $array['chrome_icon']); $this->assertSame('Title', $array['chrome_title']); $this->assertSame('Image', $array['chrome_image']); + $this->assertSame(120, $array['chrome_duration']); } } From 875c7be0c7c95033d0fa543482372e11d27d0c44 Mon Sep 17 00:00:00 2001 From: Pavel Golovin Date: Wed, 21 Feb 2018 14:28:59 +0300 Subject: [PATCH 3/3] Fix test --- src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php b/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php index c253ed7..5b970e9 100644 --- a/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php +++ b/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php @@ -89,7 +89,7 @@ public function testJsonSerialize() ->setDuration(120) ->jsonSerialize(); - $this->assertCount(4, $array); + $this->assertCount(5, $array); $this->assertSame(3600, $array['chrome_gcm_ttl']); $this->assertSame('icon', $array['chrome_icon']); $this->assertSame('Title', $array['chrome_title']);