-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tgallice/rework_attachments
Add concretes structured attachment
- Loading branch information
Showing
18 changed files
with
376 additions
and
523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace spec\Tgallice\FBMessenger\Attachment\Structured; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Tgallice\FBMessenger\Attachment; | ||
use Tgallice\FBMessenger\Attachment\Structured; | ||
use Tgallice\FBMessenger\Attachment\Structured\Button; | ||
use Tgallice\FBMessenger\Model\Button as ButtonModel; | ||
|
||
class ButtonSpec extends ObjectBehavior | ||
{ | ||
function let(ButtonModel $button) | ||
{ | ||
$this->beConstructedWith('text', [$button]); | ||
} | ||
|
||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType('Tgallice\FBMessenger\Attachment\Structured\Button'); | ||
} | ||
|
||
function it_is_a_structured_attachment() | ||
{ | ||
$this->shouldImplement(Structured::class); | ||
} | ||
|
||
function it_should_return_the_type() | ||
{ | ||
$this->getType()->shouldReturn(Attachment::TYPE_TEMPLATE); | ||
} | ||
|
||
function it_should_return_the_main_text() | ||
{ | ||
$this->getText()->shouldReturn('text'); | ||
} | ||
|
||
function it_should_return_the_buttons($button) | ||
{ | ||
$this->getButtons()->shouldReturn([$button]); | ||
} | ||
|
||
function it_should_return_the_payload($button) | ||
{ | ||
$this->getPayload()->shouldReturn([ | ||
'template_type' => Button::TEMPLATE_TYPE, | ||
'text' => 'text', | ||
'buttons' => [$button], | ||
]); | ||
} | ||
|
||
function it_should_be_serializable($button) | ||
{ | ||
$this->shouldImplement(\JsonSerializable::class); | ||
|
||
$expected = [ | ||
'type' => Attachment::TYPE_TEMPLATE, | ||
'payload' => [ | ||
'template_type' => Button::TEMPLATE_TYPE, | ||
'text' => 'text', | ||
'buttons' => [$button], | ||
], | ||
]; | ||
|
||
$this->jsonSerialize()->shouldBeLike($expected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.