Skip to content

Commit

Permalink
Fix: Sender is not always required when sending an SMS, as SMS gatewa…
Browse files Browse the repository at this point in the history
…y providers often have it optional
  • Loading branch information
felixmaier1989 committed Aug 28, 2017
1 parent 4981bac commit 7875e85
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Lib/Network/Sms/CakeSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ public function from($phoneNumber = null) {
if ($phoneNumber === null) {
return $this->_from;
}
if (empty($phoneNumber)) {
return $this;
}
return $this->_setPhoneNumber('_from', $phoneNumber);
}

Expand Down
12 changes: 11 additions & 1 deletion Test/Case/Lib/Network/Sms/CakeSmsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
App::uses('CakeSms', 'Sms.Network/Sms');
App::uses('View', 'View');

/**
* Class CakeSmsTest
* @property CakeSms $CakeSms
*/
class CakeSmsTest extends CakeTestCase {

public function setUp()
Expand Down Expand Up @@ -96,9 +100,15 @@ public function testValidatePhoneNumber1() {
$this->CakeSms->to('123456789');
}

public function testFrom() {
public function testFromSetEmpty() {
$this->CakeSms->from('');
}

public function testFromGetEmpty() {
$this->assertSame('', $this->CakeSms->from());
}

public function testFromGet() {
$this->CakeSms->from('+49123456789');
$this->assertSame('+49123456789', $this->CakeSms->from());
}
Expand Down

0 comments on commit 7875e85

Please sign in to comment.