forked from botman/botman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New method to access stored conversation questions
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
namespace BotMan\BotMan\tests\Unit; | ||
|
||
use Mockery as m; | ||
use BotMan\BotMan\BotMan; | ||
use PHPUnit_Framework_TestCase; | ||
use BotMan\BotMan\BotManFactory; | ||
use Illuminate\Support\Collection; | ||
use BotMan\BotMan\Cache\ArrayCache; | ||
use BotMan\BotMan\Drivers\Tests\FakeDriver; | ||
use BotMan\BotMan\Tests\Fixtures\TestConversation; | ||
use BotMan\BotMan\Messages\Incoming\IncomingMessage; | ||
|
||
class BotManTest extends PHPUnit_Framework_TestCase | ||
{ | ||
|
||
protected $cache; | ||
|
||
public function tearDown() | ||
{ | ||
m::close(); | ||
} | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->cache = new ArrayCache(); | ||
} | ||
|
||
/** | ||
* @param $data | ||
* @return BotMan | ||
*/ | ||
protected function getBot($data) | ||
{ | ||
$botman = BotManFactory::create([], $this->cache); | ||
|
||
$data = Collection::make($data); | ||
/** @var FakeDriver $driver */ | ||
$driver = m::mock(FakeDriver::class)->makePartial(); | ||
|
||
$driver->isBot = $data->get('is_from_bot', false); | ||
$driver->messages = [new IncomingMessage($data->get('message'), $data->get('sender'), $data->get('recipient'))]; | ||
|
||
$botman->setDriver($driver); | ||
|
||
return $botman; | ||
} | ||
|
||
/** @test */ | ||
public function it_can_return_stored_questions() | ||
{ | ||
$botman = $this->getBot([]); | ||
|
||
$botman->storeConversation(new TestConversation(), function (){}, 'This is my question'); | ||
|
||
$this->assertSame('This is my question', $botman->getStoredConversationQuestion()); | ||
} | ||
} |