Skip to content

Commit dd16c40

Browse files
committed
all tests are passing
1 parent 41ea0ec commit dd16c40

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

tests/TwitterChannelTest.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ public function it_can_send_a_status_update_notification()
3636
{
3737
$this->twitter->shouldReceive('post')
3838
->once()
39-
->with('tweets', ['text' => 'Laravel Notification Channels are awesome!'], false)
39+
->with('tweets', ['text' => 'Laravel Notification Channels are awesome!'], true)
4040
->andReturn([]);
4141

4242
$this->twitter->shouldReceive('getLastHttpCode')
4343
->once()
44-
->andReturn(200);
45-
44+
->andReturn(201);
45+
4646
$this->channel->send(new TestNotifiable(), new TestNotification());
4747
}
4848

@@ -60,8 +60,8 @@ public function it_can_send_a_status_update_notification_with_images()
6060
->once()
6161
->with(
6262
'tweets',
63-
['text' => 'Laravel Notification Channels are awesome!', 'media_ids' => '2'],
64-
false
63+
['text' => 'Laravel Notification Channels are awesome!', 'media' => [ 'media_ids' => [2]]],
64+
true
6565
)
6666
->andReturn([]);
6767

@@ -72,7 +72,7 @@ public function it_can_send_a_status_update_notification_with_images()
7272

7373
$this->twitter->shouldReceive('getLastHttpCode')
7474
->once()
75-
->andReturn(200);
75+
->andReturn(201);
7676

7777
$this->channel->send(new TestNotifiable(), new TestNotificationWithImage());
7878
}
@@ -96,8 +96,8 @@ public function it_can_send_a_status_update_notification_with_videos()
9696
->once()
9797
->with(
9898
'tweets',
99-
['text' => 'Laravel Notification Channels are awesome!', 'media_ids' => '2'],
100-
false
99+
['text' => 'Laravel Notification Channels are awesome!', 'media' => [ 'media_ids' => [2]]],
100+
true
101101
)
102102
->andReturn([]);
103103

@@ -117,13 +117,13 @@ public function it_can_send_a_status_update_notification_with_videos()
117117

118118
$this->twitter->shouldReceive('getLastHttpCode')
119119
->once()
120-
->andReturn(200);
120+
->andReturn(201);
121121

122122
$this->channel->send(new TestNotifiable(), new TestNotificationWithVideo());
123123
}
124124

125125
/** @test */
126-
public function it_can_send_a_status_update_notification_with_reply_to_status_id(): void
126+
public function it_can_send_a_status_update_notification_with_reply_to_tweet_id(): void
127127
{
128128
$postParams = [
129129
'text' => 'Laravel Notification Channels are awesome!',
@@ -132,27 +132,25 @@ public function it_can_send_a_status_update_notification_with_reply_to_status_id
132132

133133
$this->twitter->shouldReceive('post')
134134
->once()
135-
->with('tweets', $postParams, false)
135+
->with('tweets', $postParams, true)
136136
->andReturn([]);
137137

138138
$this->twitter->shouldReceive('getLastHttpCode')
139139
->once()
140-
->andReturn(200);
140+
->andReturn(201);
141141

142142
$this->channel->send(new TestNotifiable(), new TestNotificationWithReplyToStatusId($replyToStatusId));
143143
}
144144

145145
/** @test */
146146
public function it_throws_an_exception_when_it_could_not_send_the_notification()
147147
{
148-
$messageObject = new stdClass;
149-
$messageObject->message = 'Error message';
150148
$twitterResponse = new stdClass;
151-
$twitterResponse->errors[] = $messageObject;
149+
$twitterResponse->detail = 'Error Message';
152150

153151
$this->twitter->shouldReceive('post')
154152
->once()
155-
->with('tweets', ['text' => 'Laravel Notification Channels are awesome!'], false);
153+
->with('tweets', ['text' => 'Laravel Notification Channels are awesome!'], true);
156154

157155
$this->twitter->shouldReceive('getLastHttpCode')
158156
->once()
@@ -197,7 +195,7 @@ public function it_throws_an_exception_when_it_could_not_send_the_notification_w
197195
->once()
198196
->with($media->media_id_string)
199197
->andReturn($status);
200-
198+
201199
$this->expectException(CouldNotSendNotification::class);
202200

203201
$this->channel->send(new TestNotifiable(), new TestNotificationWithVideo());

tests/TwitterMessageTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ public function getApiEndpoint(): string
3636
}
3737

3838
/** @test */
39-
public function it_has_an_is_json_request_property_with_default_value_false()
39+
public function it_has_an_is_json_request_property_with_default_value_true()
4040
{
4141
$message = new class('Foo content') extends TwitterMessage
4242
{
4343
public function getApiEndpoint(): string
4444
{
45-
return 'status/update';
45+
return 'tweets';
4646
}
4747
};
4848

4949
$this->assertObjectHasAttribute('isJsonRequest', $message);
50-
$this->assertFalse($message->isJsonRequest);
50+
$this->assertTrue($message->isJsonRequest);
5151
}
5252
}

tests/TwitterStatusUpdateTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ public function it_constructs_a_request_body(): void
8888

8989
$this->assertEquals([
9090
'text' => 'myMessage',
91-
'media_ids' => '434,435,436,534,535,536',
91+
'media' => [
92+
'media_ids' => [434,435,436,534,535,536]
93+
]
9294
], $message->getRequestBody());
9395
}
9496

0 commit comments

Comments
 (0)