From 989c63acd098d4440b2543dc951a78cd78765fec Mon Sep 17 00:00:00 2001 From: Sveneld Date: Wed, 28 Feb 2024 22:36:53 +0100 Subject: [PATCH] Add SmsSenderInterface Small fixes --- src/Sms/SmsSender.php | 2 +- src/SmsConnector/DebugConnector.php | 3 ++- tests/Sms/SmsSenderTest.php | 7 +++++++ tests/SmsConnector/DebugConnectorTest.php | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Sms/SmsSender.php b/src/Sms/SmsSender.php index 9460b74..626b1a1 100644 --- a/src/Sms/SmsSender.php +++ b/src/Sms/SmsSender.php @@ -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); diff --git a/src/SmsConnector/DebugConnector.php b/src/SmsConnector/DebugConnector.php index d878f45..027378b 100644 --- a/src/SmsConnector/DebugConnector.php +++ b/src/SmsConnector/DebugConnector.php @@ -11,8 +11,9 @@ public function checkConfig(array $config) public function respond() { } + public function send($number, $text) { - echo $number. ' -> ' . $text .PHP_EOL; + echo $number . ' -> ' . $text . PHP_EOL; } } diff --git a/tests/Sms/SmsSenderTest.php b/tests/Sms/SmsSenderTest.php index e1b1de8..f7d8817 100644 --- a/tests/Sms/SmsSenderTest.php +++ b/tests/Sms/SmsSenderTest.php @@ -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)) diff --git a/tests/SmsConnector/DebugConnectorTest.php b/tests/SmsConnector/DebugConnectorTest.php index 0d1eb35..61c033c 100644 --- a/tests/SmsConnector/DebugConnectorTest.php +++ b/tests/SmsConnector/DebugConnectorTest.php @@ -11,6 +11,6 @@ public function testSend() { $debugConnector = new DebugConnector(); $debugConnector->send('123456789', 'Hello, World!'); - $this->expectOutputString('123456789 -> Hello, World!'.PHP_EOL); + $this->expectOutputString('123456789 -> Hello, World!' . PHP_EOL); } }