Skip to content

Commit

Permalink
Fix Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimpleCorey committed Aug 22, 2014
1 parent ba5b8d1 commit 5dd5539
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/SimpleSoftwareIO/SMS/Drivers/EmailSMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function send(Message $message)
$me = $this;

$this->mailer->send($this->message->getView(), $this->message->getData(), function ($email) use ($me) {
foreach ($me->message->getTo() as $number) {
foreach ($me->message->getToWithCarriers() as $number) {
$email->to($me->buildEmail($number));
}

Expand Down
26 changes: 16 additions & 10 deletions src/SimpleSoftwareIO/SMS/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,27 @@ public function to($number, $carrier = null)
}

/**
* Returns the To addresses
* Returns the To addresses without the carriers
*
* @return array
*/
public function getTo($returnCarriers = false)
public function getTo()
{
if ($returnCarriers) {
return $this->to;
} else {
$numbers = array();
foreach ($this->to as $to) {
$numbers[] = $to['number'];
}
return $numbers;
$numbers = array();
foreach ($this->to as $to) {
$numbers[] = $to['number'];
}
return $numbers;
}

/**
* Returns all numbers that a message is being sent to and includes their carriers.
*
* @return array An array with numbers and carriers
*/
public function getToWithCarriers()
{
return $this->to;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ public function testAddImages()

public function testAddToWithCarrier()
{
$toAddresses = $this->message->getTo();
$toAddresses = $this->message->getToWithCarriers();
$this->assertTrue(empty($toAddresses));

$to = [0 => ['number' => '+15555555555', 'carrier' => 'att']];
$this->message->to('+15555555555', 'att');

$this->assertEquals($to, $this->message->getTo());
$this->assertEquals($to, $this->message->getToWithCarriers());

$to = [
0 => ['number' => '+15555555555', 'carrier' => 'att'],
1 => ['number' => '+14444444444', 'carrier' => 'verizon']
];
$this->message->to('+14444444444', 'verizon');
$this->assertEquals($to, $this->message->getTo());
$this->assertEquals($to, $this->message->getToWithCarriers());
}

public function testAddToWithoutCarrier()
{
$to = [0 => ['number' => '+15555555555', 'carrier' => null]];
$to = ['+15555555555'];
$this->message->to('+15555555555');

$this->assertEquals($to, $this->message->getTo());
Expand Down

0 comments on commit 5dd5539

Please sign in to comment.