Skip to content

Commit

Permalink
Add SmsSenderInterface
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
sveneld committed Feb 28, 2024
1 parent b80ff7b commit 989c63a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Sms/SmsSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(
$this->db = $db;
}

public function send($number,$message)
public function send($number, $message)
{
if (strlen($message) > 160) {
$messageParts = str_split($message, 160);
Expand Down
3 changes: 2 additions & 1 deletion src/SmsConnector/DebugConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ public function checkConfig(array $config)
public function respond()
{
}

public function send($number, $text)
{
echo $number. ' -&gt ' . $text .PHP_EOL;
echo $number . ' -&gt ' . $text . PHP_EOL;
}
}
7 changes: 7 additions & 0 deletions tests/Sms/SmsSenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,30 @@ public function testSendShort()
$this->smsSender->send($number, $message);
}


public function testSendBig()
{
$number = '123456789';
// @codingStandardsIgnoreStart
$message = 'Hello, World! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec purus euismod mi fermentum sollicitudin. Vivamus euismod, tellus ac euismod ultricies, justo risus luctus ipsum, quis condimentum orci lacus id tellus. Sed ut ultrices mi. Nullam id orci ut mauris tincidunt tincidunt. ';
// @codingStandardsIgnoreEnd
$this->smsConnector
->expects($this->exactly(2))
->method('send')
->withConsecutive(
// @codingStandardsIgnoreStart
[$number, 'Hello, World! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec purus euismod mi fermentum sollicitudin. Vivamus euismod, tellus ac euismod'],
[$number, 'ultricies, justo risus luctus ipsum, quis condimentum orci lacus id tellus. Sed ut ultrices mi. Nullam id orci ut mauris tincidunt tincidunt.']
// @codingStandardsIgnoreEnd
);
$this->db
->expects($this->exactly(2))
->method('query')
->withConsecutive(
// @codingStandardsIgnoreStart
["INSERT INTO sent SET number='$number', text='Hello, World! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla nec purus euismod mi fermentum sollicitudin. Vivamus euismod, tellus ac euismod'"],
["INSERT INTO sent SET number='$number', text='ultricies, justo risus luctus ipsum, quis condimentum orci lacus id tellus. Sed ut ultrices mi. Nullam id orci ut mauris tincidunt tincidunt.'"]
// @codingStandardsIgnoreEnd
);
$this->db
->expects($this->exactly(2))
Expand Down
2 changes: 1 addition & 1 deletion tests/SmsConnector/DebugConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public function testSend()
{
$debugConnector = new DebugConnector();
$debugConnector->send('123456789', 'Hello, World!');
$this->expectOutputString('123456789 -&gt Hello, World!'.PHP_EOL);
$this->expectOutputString('123456789 -&gt Hello, World!' . PHP_EOL);
}
}

0 comments on commit 989c63a

Please sign in to comment.