diff --git a/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php b/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php index 3a3df26..b2b71f8 100644 --- a/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php +++ b/src/main/php/Gomoob/Pushwoosh/Model/Notification/Chrome.php @@ -41,8 +41,36 @@ class Chrome implements \JsonSerializable * * @var string */ - private $image; - + private $image; + + /** + * Text of the first button + * + * @var string + */ + private $buttonTextOne; + + /** + * Url of the first button + * + * @var + */ + private $buttonUrlOne; + + /** + * Text of the second button + * + * @var string + */ + private $buttonTextTwo; + + /** + * Url of the second button + * + * @var + */ + private $buttonUrlTwo; + /** * Utility function used to create a new Chrome instance. * @@ -62,7 +90,7 @@ public function getGcmTtl() { return $this->gcmTtl; } - + /** * Gets the full path URL to the icon, or the path to the file in resources of the extension. * @@ -72,7 +100,7 @@ public function getIcon() { return $this->icon; } - + /** * Gets the header of the message. * @@ -91,24 +119,68 @@ public function getTitle() public function getImage() { return $this->image; - } - + } + + /** + * Gets the text of the first button. + * + * @return string $text The text of the first button. + */ + public function getButtonTextOne() + { + return $this->buttonTextOne; + } + + /** + * Gets the url of the first button. + * + * @return string $url The url of the first button.* + */ + public function getButtonUrlOne() + { + return $this->buttonUrlOne; + } + + /** + * Gets the text of the second button. + * + * @return string $text The text of the second button.* + */ + public function getButtonTextTwo() + { + return $this->buttonTextTwo; + } + + /** + * Gets the url of the second button. + * + * @return string $url The url of the second button. + */ + public function getButtonUrlTwo() + { + return $this->buttonUrlTwo; + } + /** * {@inheritdoc} */ public function jsonSerialize() { $json = []; - + isset($this->gcmTtl) ? $json['chrome_gcm_ttl'] = $this->gcmTtl : false; 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->buttonTextOne) ? $json['chrome_button_text1'] = $this->buttonTextOne : false; + isset($this->buttonUrlOne) ? $json['chrome_button_url1'] = $this->buttonUrlOne : false; + isset($this->buttonTextTwo) ? $json['chrome_button_text2'] = $this->buttonTextTwo : false; + isset($this->buttonUrlTwo) ? $json['chrome_button_url2'] = $this->buttonUrlTwo : false; + return $json; - + } - + /** * Sets the time to live parameter - the maximum lifespan of a message in seconds. * @@ -119,10 +191,10 @@ public function jsonSerialize() public function setGcmTtl($gcmTtl) { $this->gcmTtl = $gcmTtl; - + return $this; } - + /** * Sets the full path URL to the icon, or the path to the file in resources of the extension. * @@ -133,10 +205,10 @@ public function setGcmTtl($gcmTtl) public function setIcon($icon) { $this->icon = $icon; - + return $this; } - + /** * Sets the header of the message. * @@ -147,7 +219,7 @@ public function setIcon($icon) public function setTitle($title) { $this->title = $title; - + return $this; } @@ -161,7 +233,63 @@ public function setTitle($title) public function setImage($image) { $this->image = $image; - + return $this; - } + } + + /** + * Sets the text of the first button. + * + * @param string $text The text of the first button. + * + * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. + */ + public function setButtonTextOne($text) + { + $this->buttonTextOne = $text; + + return $this; + } + + /** + * Sets the url of the first button. + * + * @param string $url The url of the first button. + * + * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. + */ + public function setButtonUrlOne($url) + { + $this->buttonUrlOne = $url; + + return $this; + } + + /** + * Sets the text of the second button. + * + * @param string $text The text of the second button. + * + * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. + */ + public function setButtonTextTwo($text) + { + $this->buttonTextTwo = $text; + + return $this; + } + + /** + * Sets the url of the second button. + * + * @param string $url The url of the second button. + * + * @return \Gomoob\Pushwoosh\Model\Notification\Chrome this instance. + */ + public function setButtonUrlTwo($url) + { + $this->buttonUrlTwo = $url; + + return $this; + } } diff --git a/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php b/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php index 73d41af..789dfe3 100644 --- a/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php +++ b/src/test/php/Gomoob/Pushwoosh/Model/Notification/ChromeTest.php @@ -64,8 +64,48 @@ public function testGetSetImage() $chrome = new Chrome(); $this->assertSame($chrome, $chrome->setImage('Image')); $this->assertSame('Image', $chrome->getImage()); - } - + } + + /** + * Test method for the #getButtonTextOne() and #setButtonTextOne($text) functions. + */ + public function testGetButtonTextOne() + { + $chrome = new Chrome(); + $this->assertSame($chrome, $chrome->setButtonTextOne('ButtonTextOne')); + $this->assertSame('ButtonTextOne', $chrome->getButtonTextOne()); + } + + /** + * Test method for the #getButtonUrlOne() and #setButtonUrlOne($url) functions. + */ + public function testGetButtonUrlOne() + { + $chrome = new Chrome(); + $this->assertSame($chrome, $chrome->setButtonUrlOne('ButtonUrlOne')); + $this->assertSame('ButtonUrlOne', $chrome->getButtonUrlOne()); + } + + /** + * Test method for the #getButtonTextTwo() and #setButtonTextTwo($text) functions. + */ + public function testGetButtonTextTwo() + { + $chrome = new Chrome(); + $this->assertSame($chrome, $chrome->setButtonTextTwo('ButtonTextTwo')); + $this->assertSame('ButtonTextTwo', $chrome->getButtonTextTwo()); + } + + /** + * Test method for the #getButtonUrlTwo() and #setButtonUrlTwo($url) functions. + */ + public function testGetButtonUrlTwo() + { + $chrome = new Chrome(); + $this->assertSame($chrome, $chrome->setButtonUrlTwo('ButtonUrlTwo')); + $this->assertSame('ButtonUrlTwo', $chrome->getButtonUrlTwo()); + } + /** * Test method for the #jsonSerialize() function. */ @@ -76,12 +116,20 @@ public function testJsonSerialize() ->setIcon('icon') ->setTitle('Title') ->setImage('Image') + ->setButtonTextOne('ButtonTextOne') + ->setButtonUrlOne('ButtonUrlOne') + ->setButtonTextTwo('ButtonTextTwo') + ->setButtonUrlTwo('ButtonUrlTwo') ->jsonSerialize(); - $this->assertCount(4, $array); + $this->assertCount(8, $array); $this->assertSame(3600, $array['chrome_gcm_ttl']); $this->assertSame('icon', $array['chrome_icon']); $this->assertSame('Title', $array['chrome_title']); $this->assertSame('Image', $array['chrome_image']); + $this->assertSame('ButtonTextOne', $array['chrome_button_text1']); + $this->assertSame('ButtonUrlOne', $array['chrome_button_url1']); + $this->assertSame('ButtonTextTwo', $array['chrome_button_text2']); + $this->assertSame('ButtonUrlTwo', $array['chrome_button_url2']); } } diff --git a/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php b/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php index 244e711..d488392 100644 --- a/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php +++ b/src/test/php/Gomoob/Pushwoosh/Model/Notification/NotificationTest.php @@ -542,6 +542,10 @@ public function testJsonSerialize() ->setIcon('icon') ->setTitle('Title') ->setImage('Image') + ->setButtonTextOne('ButtonTextOne') + ->setButtonUrlOne('ButtonUrlOne') + ->setButtonTextTwo('ButtonTextTwo') + ->setButtonUrlTwo('ButtonUrlTwo') ) ->setIOS( IOS::create() @@ -590,7 +594,7 @@ public function testJsonSerialize() ->jsonSerialize(); // Test the generic properties - $this->assertCount(65, $array); + $this->assertCount(69, $array); $this->assertSame('now', $array['send_date']); $this->assertSame('America/New_York', $array['timezone']); $this->assertTrue($array['ignore_user_timezone']); @@ -668,6 +672,10 @@ public function testJsonSerialize() $this->assertSame('icon', $array['chrome_icon']); $this->assertSame('Title', $array['chrome_title']); $this->assertSame('Image', $array['chrome_image']); + $this->assertSame('ButtonTextOne', $array['chrome_button_text1']); + $this->assertSame('ButtonUrlOne', $array['chrome_button_url1']); + $this->assertSame('ButtonTextTwo', $array['chrome_button_text2']); + $this->assertSame('ButtonUrlTwo', $array['chrome_button_url2']); // Test IOS parameters $this->assertSame(1, $array['apns_trim_content']);