Skip to content

Commit

Permalink
Fix issue when manually creating share buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
mpociot committed Nov 20, 2017
1 parent 14c6fa0 commit 66db63d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Extensions/ElementButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function toArray()
$buttonArray['fallback_url'] = $this->fallback_url ?: $this->url;
}
}
} elseif ($this->type == self::TYPE_SHARE) {
} elseif ($this->type == self::TYPE_SHARE && !is_null($this->shareContents)) {
$buttonArray['share_contents'] = $this->shareContents->toArray();
}

Expand Down
16 changes: 16 additions & 0 deletions tests/Extensions/ElementButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,20 @@ public function it_can_set_share_contents()

$this->assertSame($share->toArray(), Arr::get($button->toArray(), 'share_contents'));
}

/**
* @test
**/
public function it_can_share_contents_with_manual_assigned_buttons()
{
$share = ElementButton::create('Share')
->type(ElementButton::TYPE_SHARE)
->url('https://botman.io');

$payload = [
'type' => 'element_share',
];

$this->assertSame($share->toArray(), $payload);
}
}

0 comments on commit 66db63d

Please sign in to comment.