mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-05 11:32:12 +09:00
Minor changes to support unit testing via dummy
This commit is contained in:
parent
a92c77655f
commit
aab6bd6d48
2 changed files with 38 additions and 3 deletions
|
|
@ -32,6 +32,11 @@ class Dummy extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
'delay_supported' => true,
|
||||
);
|
||||
|
||||
/**
|
||||
* Sent messages are stored here for debugging and testing.
|
||||
*/
|
||||
protected $_sent_messages = array();
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
|
|
@ -43,6 +48,30 @@ class Dummy extends Base implements \Rhymix\Framework\Drivers\SMSInterface
|
|||
*/
|
||||
public function send(array $messages, \Rhymix\Framework\SMS $original)
|
||||
{
|
||||
foreach ($messages as $message)
|
||||
{
|
||||
$this->_sent_messages[] = $message;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sent messages.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getSentMessages()
|
||||
{
|
||||
return $this->_sent_messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset sent messages.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function resetSentMessages()
|
||||
{
|
||||
$this->_sent_messages = array();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class SMS
|
|||
*/
|
||||
public $driver = null;
|
||||
protected $caller = '';
|
||||
protected $from = '';
|
||||
protected $from = null;
|
||||
protected $to = array();
|
||||
protected $subject = '';
|
||||
protected $content = '';
|
||||
|
|
@ -91,6 +91,7 @@ class SMS
|
|||
'name' => $class_name::getName(),
|
||||
'required' => $class_name::getRequiredConfig(),
|
||||
'api_types' => $class_name::getAPITypes(),
|
||||
'api_spec' => $class_name::getAPISpec(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -102,6 +103,7 @@ class SMS
|
|||
'name' => $driver->getName(),
|
||||
'required' => $driver->getRequiredConfig(),
|
||||
'api_types' => $driver->getAPITypes(),
|
||||
'api_spec' => $class_name::getAPISpec(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +117,7 @@ class SMS
|
|||
public function __construct()
|
||||
{
|
||||
$this->driver = self::getDefaultDriver();
|
||||
$this->from = trim(config('sms.default_from'));
|
||||
$this->from = trim(preg_replace('/[^0-9]/', '', config('sms.default_from'))) ?: null;
|
||||
$this->allow_split_sms = (config('sms.allow_split.sms') !== false);
|
||||
$this->allow_split_lms = (config('sms.allow_split.lms') !== false);
|
||||
}
|
||||
|
|
@ -135,7 +137,7 @@ class SMS
|
|||
/**
|
||||
* Get the sender's phone number.
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFrom()
|
||||
{
|
||||
|
|
@ -336,6 +338,10 @@ class SMS
|
|||
{
|
||||
$when = time() + $when;
|
||||
}
|
||||
if ($when <= time())
|
||||
{
|
||||
$when = 0;
|
||||
}
|
||||
|
||||
$this->delay_timestamp = intval($when);
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue