MessageTest.php 1.98 KB
Newer Older
Juliper committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
<?php

/**
 * Simple-SMS
 * Simple-SMS is a package made for Laravel to send/receive (polling/pushing) text messages.
 *
 * @link http://www.simplesoftware.io
 * @author SimpleSoftware support@simplesoftware.io
 *
 */

use Mockery as m;
use SimpleSoftwareIO\SMS\OutgoingMessage;

class MessageTest extends \PHPUnit_Framework_TestCase {

  public function tearDown()
  {
    m::close();
  }

  public function setUp()
  {
    $this->message = new OutgoingMessage(m::mock('\Illuminate\View\Factory'));
  }

  public function testMSMIsSetOnAttachImage()
  {
    $this->assertFalse($this->message->isMMS());

    $this->message->attachImage('foo.jpg');

    $this->assertTrue($this->message->isMMS());
  }

  public function testAddImage()
  {
    $images = $this->message->getAttachImages();

    $this->assertTrue(empty($images));

    $singleImage = [0 => 'foo.jpg'];
    $this->message->attachImage('foo.jpg');
    $images = $this->message->getAttachImages();

    $this->assertEquals($singleImage, $images);
  }

  public function testAddImages()
  {
    $mutiImage = [0 => 'foo.jpg', 1 => 'bar.jpg'];
    $this->message->attachImage(['foo.jpg', 'bar.jpg']);
    $images = $this->message->getAttachImages();

    $this->assertEquals($mutiImage, $images);
  }

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

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

    $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->getToWithCarriers());
  }

  public function testAddToWithoutCarrier()
  {
    $to = ['+15555555555'];
    $this->message->to('+15555555555');

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

}