/** * @test */ public function it_construct_a_valid_json_with_notification() { $targetPartial = '{ "title":"test_title", "body":"test_body", "badge":"test_badge", "sound":"test_sound" }'; $targetFull = '{ "title":"test_title", "body":"test_body", "badge":"test_badge", "sound":"test_sound", "tag":"test_tag", "color":"test_color", "click_action":"test_click_action", "body_loc_key":"test_body_key", "body_loc_args":"[ body0, body1 ]", "title_loc_key":"test_title_key", "title_loc_args":"[ title0, title1 ]", "icon":"test_icon" }'; $notificationBuilder = new PayloadNotificationBuilder(); $notificationBuilder->setTitle('test_title')->setBody('test_body')->setSound('test_sound')->setBadge('test_badge'); $json = json_encode($notificationBuilder->build()->toArray()); $this->assertJsonStringEqualsJsonString($targetPartial, $json); $notificationBuilder->setTag('test_tag')->setColor('test_color')->setClickAction('test_click_action')->setBodyLocationKey('test_body_key')->setBodyLocationArgs('[ body0, body1 ]')->setTitleLocationKey('test_title_key')->setTitleLocationArgs('[ title0, title1 ]')->setIcon('test_icon'); $json = json_encode($notificationBuilder->build()->toArray()); $this->assertJsonStringEqualsJsonString($targetFull, $json); }
/** * PayloadNotification constructor. * * @param PayloadNotificationBuilder $builder */ public function __construct(PayloadNotificationBuilder $builder) { $this->title = $builder->getTitle(); $this->body = $builder->getBody(); $this->icon = $builder->getIcon(); $this->sound = $builder->getSound(); $this->badge = $builder->getBadge(); $this->tag = $builder->getTag(); $this->color = $builder->getColor(); $this->clickAction = $builder->getClickAction(); $this->bodyLocationKey = $builder->getBodyLocationKey(); $this->bodyLocationArgs = $builder->getBodyLocationArgs(); $this->titleLocationKey = $builder->getTitleLocationKey(); $this->titleLocationArgs = $builder->getTitleLocationArgs(); }