Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased](https://github.com/pusher/chatkit-server-php/compare/1.2.0...HEAD)

### Fixed

- `fetchMultipartMessages` now uses passed query params

## [1.2.0](https://github.com/pusher/chatkit-server-php/compare/1.1.0...1.2.0) - 2019-03-08

### Added
Expand Down
1 change: 1 addition & 0 deletions src/Chatkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,7 @@ protected function getOptionalFields($field_names, $options) {
$fields[$field_name] = $options[$field_name];
}
}
return $fields;
}

/**
Expand Down
42 changes: 41 additions & 1 deletion tests/v3/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testFetchMultipartMessagesShouldReturnAResponsePayloadIfARoomIDL
]);

$this->assertEquals(200, $get_msg_res['status']);
$this->assertEquals(count($messages), count($get_msg_res['body']));
$this->assertEquals(count($sliced_messages), count($get_msg_res['body']));

$parts = [ $get_msg_res['body'][0]['parts'][0],
$get_msg_res['body'][1]['parts'][0] ];
Expand All @@ -176,6 +176,46 @@ public function testFetchMultipartMessagesShouldReturnAResponsePayloadIfARoomIDL
}
}

public function testFetchMultipartMessagesShouldReturnAResponsePayloadIfARoomIDAndNewerDirectionAreProvided()
{
$user_id = $this->makeUser();
$room_id = $this->makeRoom($user_id);

$messages = $this->makeMessages($room_id, [ [$user_id => 'hi first'],
[$user_id => 'hi last'],
]);

$get_msg_res = $this->chatkit->fetchMultipartMessages([
'room_id' => $room_id,
'direction' => 'newer',
]);

$this->assertEquals(200, $get_msg_res['status']);
$this->assertEquals(count($messages), count($get_msg_res['body']));
$this->assertEquals(array_values($messages)[0], $get_msg_res['body'][0]['parts'][0]['content']);
$this->assertEquals(array_values($messages)[1], $get_msg_res['body'][1]['parts'][0]['content']);
}

public function testFetchMultipartMessagesShouldReturnAResponsePayloadIfARoomIDAndOlderDirectionAreProvided()
{
$user_id = $this->makeUser();
$room_id = $this->makeRoom($user_id);

$messages = $this->makeMessages($room_id, [ [$user_id => 'hi first'],
[$user_id => 'hi last'],
]);

$get_msg_res = $this->chatkit->fetchMultipartMessages([
'room_id' => $room_id,
'direction' => 'older',
]);

$this->assertEquals(200, $get_msg_res['status']);
$this->assertEquals(count($messages), count($get_msg_res['body']));
$this->assertEquals(array_values($messages)[0], $get_msg_res['body'][1]['parts'][0]['content']);
$this->assertEquals(array_values($messages)[1], $get_msg_res['body'][0]['parts'][0]['content']);
}

public function testFetchMultipartMessagesShouldReturnAResponsePayloadIfAnAttachmentProvided()
{
$user_id = $this->makeUser();
Expand Down