-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathWebUrlSpec.php
More file actions
135 lines (110 loc) · 3.59 KB
/
Copy pathWebUrlSpec.php
File metadata and controls
135 lines (110 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
namespace spec\Tgallice\FBMessenger\Model\Button;
use PhpSpec\ObjectBehavior;
use Tgallice\FBMessenger\Model\Button;
use Tgallice\FBMessenger\Model\Button\WebUrl;
class WebUrlSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('title', 'http://www.google.com');
}
function it_is_initializable()
{
$this->shouldHaveType('Tgallice\FBMessenger\Model\Button\WebUrl');
}
function it_is_a_button()
{
$this->shouldImplement(Button::class);
}
function it_has_a_type()
{
$this->getType()->shouldReturn(Button::TYPE_WEB_URL);
}
function it_has_a_title()
{
$this->getTitle()->shouldReturn('title');
}
function it_has_an_url()
{
$this->getUrl()->shouldReturn('http://www.google.com');
}
function it_has_a_webview_height_ratio()
{
$this->getWebviewHeightRatio()->shouldReturn(WebUrl::HEIGHT_RATIO_FULL);
}
function it_has_a_webview_share_button()
{
$this->getWebviewShareButton()->shouldReturn(WebUrl::WEBVIEW_SHARE_BUTTON_SHOW);
}
function it_not_using_messenger_extensions()
{
$this->useMessengerExtensions()->shouldReturn(false);
}
function it_has_not_default_fallback_url()
{
$this->getFallbackUrl()->shouldReturn(null);
}
function its_webview_height_ratio_is_mutable()
{
$this->setWebviewHeightRatio(WebUrl::HEIGHT_RATIO_TALL);
$this->getWebviewHeightRatio()->shouldReturn(WebUrl::HEIGHT_RATIO_TALL);
}
function its_webview_share_button_is_mutable()
{
$this->setWebviewShareButton(WebUrl::WEBVIEW_SHARE_BUTTON_HIDE);
$this->getWebviewShareButton()->shouldReturn(WebUrl::WEBVIEW_SHARE_BUTTON_HIDE);
}
function its_messenger_extensions_is_mutable()
{
$this->setMessengerExtensions(true);
$this->useMessengerExtensions()->shouldReturn(true);
}
function its_fallback_url_is_mutable()
{
$this->setFallbackUrl('url');
$this->getFallbackUrl()->shouldReturn('url');
}
function it_throw_an_exception_if_set_an_invalid_webview_height()
{
$this
->shouldThrow(new \InvalidArgumentException('Webview height ratio must be one of this values: [full, compact, tall]'))
->duringSetWebviewHeightRatio('ok');
}
function it_should_be_serializable()
{
$this->shouldImplement(\JsonSerializable::class);
$expected = [
'type' => 'web_url',
'title' => 'title',
'url' => 'http://www.google.com',
'webview_height_ratio' => 'full',
'webview_share_button' => 'show'
];
$this->jsonSerialize()->shouldBeLike($expected);
}
function it_should_be_full_serializable()
{
$this->setMessengerExtensions(true);
$this->setFallbackUrl('fallback url');
$expected = [
'type' => 'web_url',
'title' => 'title',
'url' => 'http://www.google.com',
'webview_height_ratio' => 'full',
'webview_share_button' => 'show',
'messenger_extensions' => true,
'fallback_url' => 'fallback url',
];
$this->jsonSerialize()->shouldBeLike($expected);
}
function it_throws_exception_when_the_title_exceed_20_characters()
{
$this->beConstructedWith(str_repeat('title', 5), 'url');
$this
->shouldThrow(new \InvalidArgumentException(
'The button title field should not exceed 20 characters.'
))
->duringInstantiation();
}
}