first commit
This commit is contained in:
90
bundles/KupShop/TelfaBundle/Tests/TelfaSmsTest.php
Normal file
90
bundles/KupShop/TelfaBundle/Tests/TelfaSmsTest.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\DevelopmentBundle\Tests;
|
||||
|
||||
use KupShop\DevelopmentBundle\MailArchive;
|
||||
use KupShop\DevelopmentBundle\Util\Tests\ContainerAwareTestTrait;
|
||||
use KupShop\TelfaBundle\Utils\SMSHandler;
|
||||
|
||||
class TelfaSmsTest extends \DatabaseTestCase
|
||||
{
|
||||
use ContainerAwareTestTrait;
|
||||
|
||||
/** @var MailArchive */
|
||||
protected $mailArchive;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->mailArchive = $this->get(MailArchive::class);
|
||||
$this->mailArchive->clearArchive();
|
||||
}
|
||||
|
||||
public function testSmsArchive()
|
||||
{
|
||||
$sms = $this->get(SMSHandler::class);
|
||||
\Settings::getDefault()->saveValue('telfa', ['sms_number_id' => '1']);
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
|
||||
$this->assertEquals([['body' => 'foo', 'to' => '623456789', 'time' => date('Y-m-d H:i:s'), 'number_id' => 1]], $this->mailArchive->getArchive());
|
||||
}
|
||||
|
||||
public function testSmsArchiveException()
|
||||
{
|
||||
$sms = $this->get(SMSHandler::class);
|
||||
|
||||
$resp = $sms->sendSMS(623456789, 'foo');
|
||||
|
||||
$this->assertEquals('SMS neodeslána, zkuste to prosím za okamžik znovu.', $resp);
|
||||
}
|
||||
|
||||
public function testChangeSIMNumbers()
|
||||
{
|
||||
$sms = $this->get(SMSHandler::class);
|
||||
\Settings::getDefault()->saveValue('telfa', ['sms_number_id' => '1;2;3']);
|
||||
|
||||
$this->assertEquals(1, $sms->getSIMId());
|
||||
$this->assertEquals(2, $sms->getSIMId());
|
||||
$this->assertEquals(3, $sms->getSIMId());
|
||||
$this->assertEquals(1, $sms->getSIMId());
|
||||
}
|
||||
|
||||
public function testSmsMultipleSIM()
|
||||
{
|
||||
$sms = $this->get(SMSHandler::class);
|
||||
$dbcfg = \Settings::getDefault();
|
||||
$dbcfg->telfa['sms_number_id'] = '1;2;3';
|
||||
$dbcfg->saveToDB();
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(1, $this->mailArchive->getLast()['number_id']);
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(2, $this->mailArchive->getLast()['number_id']);
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(3, $this->mailArchive->getLast()['number_id']);
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(1, $this->mailArchive->getLast()['number_id']);
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(2, $this->mailArchive->getLast()['number_id']);
|
||||
}
|
||||
|
||||
public function testSmsSimpleSIM()
|
||||
{
|
||||
$sms = $this->get(SMSHandler::class);
|
||||
\Settings::getDefault()->saveValue('telfa', ['sms_number_id' => '5874']);
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(5874, $this->mailArchive->getLast()['number_id']);
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(5874, $this->mailArchive->getLast()['number_id']);
|
||||
|
||||
$sms->sendSMS(623456789, 'foo');
|
||||
$this->assertEquals(5874, $this->mailArchive->getLast()['number_id']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user