Skip to content

Commit 2f6caa8

Browse files
committed
Change test to be simple!
1 parent b534664 commit 2f6caa8

File tree

1 file changed

+12
-54
lines changed

1 file changed

+12
-54
lines changed

tests/LINEBot/SendTemplateTest.php

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -110,65 +110,22 @@ public function testPushTemplate()
110110
$testRunner->assertEquals('https://example.com/thumbnail.jpg', $template['thumbnailImageUrl']);
111111

112112
$actions = $template['actions'];
113-
$testRunner->assertEquals(3, count($actions));
113+
$testRunner->assertEquals(4, count($actions));
114114
$testRunner->assertEquals(ActionType::POSTBACK, $actions[0]['type']);
115115
$testRunner->assertEquals('postback label', $actions[0]['label']);
116116
$testRunner->assertEquals('post=back', $actions[0]['data']);
117117

118-
$testRunner->assertEquals(ActionType::MESSAGE, $actions[1]['type']);
119-
$testRunner->assertEquals('message label', $actions[1]['label']);
120-
$testRunner->assertEquals('test message', $actions[1]['text']);
121-
122-
$testRunner->assertEquals(ActionType::URI, $actions[2]['type']);
123-
$testRunner->assertEquals('uri label', $actions[2]['label']);
124-
$testRunner->assertEquals('https://example.com', $actions[2]['uri']);
125-
126-
return ['status' => 200];
127-
};
128-
$bot = new LINEBot(new DummyHttpClient($this, $mock), ['channelSecret' => 'CHANNEL-SECRET']);
129-
$res = $bot->pushMessage(
130-
'DESTINATION',
131-
new LINEBot\MessageBuilder\TemplateMessageBuilder(
132-
'alt test',
133-
new ButtonTemplateBuilder(
134-
'button title',
135-
'button button',
136-
'https://example.com/thumbnail.jpg',
137-
[
138-
new PostbackTemplateActionBuilder('postback label', 'post=back'),
139-
new MessageTemplateActionBuilder('message label', 'test message'),
140-
new UriTemplateActionBuilder('uri label', 'https://example.com'),
141-
]
142-
)
143-
)
144-
);
145-
146-
$this->assertEquals(200, $res->getHTTPStatus());
147-
$this->assertTrue($res->isSucceeded());
148-
$this->assertEquals(200, $res->getJSONDecodedBody()['status']);
149-
}
118+
$testRunner->assertEquals(ActionType::POSTBACK, $actions[1]['type']);
119+
$testRunner->assertEquals('postback label2', $actions[1]['label']);
120+
$testRunner->assertEquals('post=back2', $actions[1]['data']);
150121

151-
public function testPushTemplateWithText()
152-
{
153-
// Support text field on postback template
154-
// Ref: https://github.com/line/line-bot-sdk-php/issues/47
155-
$mock = function ($testRunner, $httpMethod, $url, $data) {
156-
/** @var \PHPUnit_Framework_TestCase $testRunner */
157-
$testRunner->assertEquals('POST', $httpMethod);
158-
$testRunner->assertEquals('https://api.line.me/v2/bot/message/push', $url);
122+
$testRunner->assertEquals(ActionType::MESSAGE, $actions[2]['type']);
123+
$testRunner->assertEquals('message label', $actions[2]['label']);
124+
$testRunner->assertEquals('test message', $actions[2]['text']);
159125

160-
$testRunner->assertEquals('DESTINATION', $data['to']);
161-
$testRunner->assertEquals(1, count($data['messages']));
162-
163-
$message = $data['messages'][0];
164-
$template = $message['template'];
165-
$actions = $template['actions'];
166-
167-
$testRunner->assertEquals(3, count($actions));
168-
$testRunner->assertEquals(ActionType::POSTBACK, $actions[0]['type']);
169-
$testRunner->assertEquals('postback label', $actions[0]['label']);
170-
$testRunner->assertEquals('post=back', $actions[0]['data']);
171-
$testRunner->assertEquals('extend text', $actions[0]['text']);
126+
$testRunner->assertEquals(ActionType::URI, $actions[3]['type']);
127+
$testRunner->assertEquals('uri label', $actions[3]['label']);
128+
$testRunner->assertEquals('https://example.com', $actions[3]['uri']);
172129

173130
return ['status' => 200];
174131
};
@@ -182,7 +139,8 @@ public function testPushTemplateWithText()
182139
'button button',
183140
'https://example.com/thumbnail.jpg',
184141
[
185-
new PostbackTemplateActionBuilder('postback label', 'post=back', 'extend text'), // <= Test here
142+
new PostbackTemplateActionBuilder('postback label', 'post=back'),
143+
new PostbackTemplateActionBuilder('postback label2', 'post=back2', 'extend text'),
186144
new MessageTemplateActionBuilder('message label', 'test message'),
187145
new UriTemplateActionBuilder('uri label', 'https://example.com'),
188146
]

0 commit comments

Comments
 (0)