summaryrefslogtreecommitdiffstats
path: root/tests/SMS/OutGoingSMSTest.php
blob: 9ac870b9a491f63593371760e1c995cd3c2a7f2f (plain)
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
<?php
/**
* PHP version 7.1.1
* @author Hannes Kindströmmer <hannes@kindstrommer.se>
* @copyright 2017 iP.1 Networks AB
* @license https://www.gnu.org/licenses/lgpl-3.0.txt LGPL-3.0
* @version 0.2.0-beta
* @since File available since Release 0.1.0-beta
* @link http://api.ip1sms.com/Help
* @link https://github.com/iP1SMS/ip1-php-sdk
*/


namespace IP1\RESTClient\Test\SMS;

use PHPUnit\Framework\TestCase;
use PHPUnit\Exception;
use IP1\RESTClient\SMS\OutGoingSMS;
use IP1\RESTClient\Recipient\Contact;
use IP1\RESTClient\Recipient\RecipientFactory;
use IP1\RESTClient\Exception\UndefinedOffsetException;
use IP1\RESTClient\Test\Core\AbstractEnviromentProvider;

/**
 * Tests for the \IP1\RESTClient\SMS\OutGoingSMS class
 */
class OutGoingSMSTest extends AbstractEnviromentProvider
{

    public function testAddRecipient()
    {
        $contact = RecipientFactory::createProcessedContactFromJSON(
            file_get_contents('tests/resources/processed_contact/processed_contact.json')
        );

        $sms = new OutGoingSMS("Jack", "Why is the rum gone?");
        $sms->addNumber("12025550111");
        $sms->addContact($contact);
        $stdSMS = json_decode(json_encode($sms));
        $this->assertEquals([1735500], $stdSMS->Contacts);
    }

    public function testNumbers()
    {
        $sms = new OutGoingSMS("Jack", "Why is the rum gone?");
        $sms->addNumber("12025550111");
        $this->assertEquals(1, count($sms->getAllNumbers()));
        $sms->removeNumber(0);
        $this->assertEquals(0, count($sms->getAllNumbers()));
        $sms->addAllNumbers(['12025550111','12025550112','12025550113']);
        $this->assertEquals(['12025550111','12025550112','12025550113'], $sms->getAllNumbers());
        $sms->addNumber('12025550114');
        $sms->addAllNumbers(['12025550115','12025550116','12025550117']);
        $this->assertEquals(
            ['12025550111','12025550112','12025550113', '12025550114', '12025550115','12025550116','12025550117'],
            $sms->getAllNumbers()
        );
        $sms->removeNumber(1);
        $this->assertEquals(
            ['12025550111','12025550113', '12025550114', '12025550115','12025550116','12025550117'],
            $sms->getAllNumbers()
        );
    }
}