first commit
This commit is contained in:
74
bundles/KupShop/TelfaBundle/Tests/TelfaTest.php
Normal file
74
bundles/KupShop/TelfaBundle/Tests/TelfaTest.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
use KupShop\TelfaBundle\Utils\SMSHandler;
|
||||
|
||||
class TelfaTest extends \DatabaseTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testCache()
|
||||
{
|
||||
$testValue = 'test';
|
||||
setCache($testValue, $testValue);
|
||||
$this->assertEquals($testValue, getCache($testValue));
|
||||
}
|
||||
|
||||
public function testIncommingSMSWithOrder()
|
||||
{
|
||||
$sms = /* @lang JSON */ '[{"id":123, "sender": "774123456", "message": "hello"}]';
|
||||
|
||||
$telfa = $this->createPartialMock(SMSHandler::class, ['getSMS']);
|
||||
|
||||
$telfa->expects($this->any())
|
||||
->method('getSMS')
|
||||
->willReturn(json_decode_strict($sms));
|
||||
|
||||
$telfa->synchronizeIncomingSMS();
|
||||
|
||||
$mailArchive = $this->get(\KupShop\DevelopmentBundle\MailArchive::class);
|
||||
$this->assertContains('hello', $mailArchive->getLast()['body']);
|
||||
|
||||
$order = new Order(1);
|
||||
$history = $order->getHistory(true);
|
||||
$this->assertContains('hello', end($history)['comment']); // SMS message
|
||||
|
||||
$mailArchive = $this->get(\KupShop\DevelopmentBundle\MailArchive::class);
|
||||
$this->assertContains('201300025', $mailArchive->getLast()['body']); // Order code
|
||||
}
|
||||
|
||||
public function testIncommingSMSWithoutAnyOrder()
|
||||
{
|
||||
$sms = /* @lang JSON */ '[{"id":123, "sender": "noname", "message": "hello"}]';
|
||||
|
||||
$telfa = $this->createPartialMock(SMSHandler::class, ['getSMS']);
|
||||
|
||||
$telfa->expects($this->any())
|
||||
->method('getSMS')
|
||||
->willReturn(json_decode_strict($sms));
|
||||
|
||||
$telfa->synchronizeIncomingSMS();
|
||||
|
||||
$mailArchive = $this->get(\KupShop\DevelopmentBundle\MailArchive::class);
|
||||
$this->assertContains('Tato sms nebyla přiřazená k žádné objednávce', $mailArchive->getLast()['body']);
|
||||
}
|
||||
|
||||
protected function getDataSet()
|
||||
{
|
||||
return $this->getJsonDataSet(/* @lang JSON */ '{
|
||||
"orders_history": [
|
||||
{
|
||||
"id":36,
|
||||
"id_order":1,
|
||||
"id_status":2,
|
||||
"date":"2013-09-13 13:50:19",
|
||||
"comment":"",
|
||||
"admin":null,
|
||||
"notified":2
|
||||
}
|
||||
]
|
||||
}');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user