Skip to content

Commit

Permalink
Tests added.
Browse files Browse the repository at this point in the history
  • Loading branch information
halilcosdu committed Apr 17, 2024
1 parent 8fa993a commit 8056b14
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 5 deletions.
57 changes: 57 additions & 0 deletions tests/ChatBotTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

use HalilCosdu\ChatBot\ChatBot;
use HalilCosdu\ChatBot\Services\ChatBotService;
use Mockery as m;

beforeEach(function () {
$chatBotService = m::mock(ChatBotService::class);
$chatBot = new ChatBot($chatBotService);

$this->chatBotService = $chatBotService;
$this->chatBot = $chatBot;
});

it('lists threads', function () {
$mockedThreads = new \Illuminate\Pagination\LengthAwarePaginator([], 0, 10);
$this->chatBotService->shouldReceive('index')->once()->andReturn($mockedThreads);

$result = $this->chatBot->listThreads();

expect($result)->toBe($mockedThreads);
});

it('creates a thread', function () {
$mockedThread = new \HalilCosdu\ChatBot\Models\Thread();
$this->chatBotService->shouldReceive('create')->once()->andReturn($mockedThread);

$result = $this->chatBot->createThread('subject test');

expect($result)->toBe($mockedThread);
});

it('retrieves a thread', function () {
$mockedThread = new \HalilCosdu\ChatBot\Models\Thread();
$this->chatBotService->shouldReceive('show')->once()->andReturn($mockedThread);

$result = $this->chatBot->thread(1);

expect($result)->toBe($mockedThread);
});

it('updates a thread', function () {
$mockedThread = new \HalilCosdu\ChatBot\Models\Thread();
$this->chatBotService->shouldReceive('update')->once()->andReturn($mockedThread);

$result = $this->chatBot->updateThread('new message', 1);

expect($result)->toBe($mockedThread);
});

it('deletes a thread', function () {
$this->chatBotService->shouldReceive('delete')->once();

$this->chatBot->deleteThread(1);

expect(true);
});
5 changes: 0 additions & 5 deletions tests/ExampleTest.php

This file was deleted.

0 comments on commit 8056b14

Please sign in to comment.