mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-10-06 20:10:31 +00:00
Update tests and Throw InvalidArgumentException when building an empty comment body
This commit is contained in:
@@ -1382,6 +1382,21 @@ final class ApiTest extends TestCase
|
||||
$this->assertSame([], $this->api->getComments('mid.post'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function getCommentsTreatsEmptyCommentIdsListAsNoFilter(): void
|
||||
{
|
||||
$this->clientMock->expects($this->once())
|
||||
->method('request')
|
||||
->with('GET', '/messages/mid.post/comments', [])
|
||||
->willReturn(['messages' => []]);
|
||||
|
||||
$this->modelFactoryMock->expects($this->once())
|
||||
->method('createCommentMessages')
|
||||
->willReturn([]);
|
||||
|
||||
$this->assertSame([], $this->api->getComments('mid.post', []));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function getCommentByIdRequestsTheSingleComment(): void
|
||||
{
|
||||
@@ -1427,6 +1442,21 @@ final class ApiTest extends TestCase
|
||||
$this->assertSame($expectedComment, $result);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function sendCommentOmitsDisableLinkPreviewWhenFalse(): void
|
||||
{
|
||||
$this->clientMock->expects($this->once())
|
||||
->method('request')
|
||||
->with('POST', '/messages/mid.post/comments', [], ['text' => 'Nice post'])
|
||||
->willReturn(['message' => $this->commentData()]);
|
||||
|
||||
$this->modelFactoryMock->expects($this->once())
|
||||
->method('createCommentMessageFromSendResponse')
|
||||
->willReturn($this->comment());
|
||||
|
||||
$this->api->sendComment('mid.post', 'Nice post');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function editCommentPutsNewTextForTheComment(): void
|
||||
{
|
||||
@@ -1445,6 +1475,28 @@ final class ApiTest extends TestCase
|
||||
$this->assertSame($expectedResult, $this->api->editComment('mid.post', 'mid.comment', 'Edited'));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function sendCommentWithoutAnyFieldThrowsInvalidArgumentException(): void
|
||||
{
|
||||
$this->clientMock->expects($this->never())->method('request');
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('At least one of $text, $format or $link must be provided');
|
||||
|
||||
$this->api->sendComment('mid.post');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function editCommentWithoutAnyFieldThrowsInvalidArgumentException(): void
|
||||
{
|
||||
$this->clientMock->expects($this->never())->method('request');
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('At least one of $text, $format or $link must be provided');
|
||||
|
||||
$this->api->editComment('mid.post', 'mid.comment');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function deleteCommentDeletesByCommentId(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user