-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathSMSTest.php
More file actions
38 lines (31 loc) · 1.22 KB
/
SMSTest.php
File metadata and controls
38 lines (31 loc) · 1.22 KB
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
<?php
namespace Utopia\Tests\Adapter\SMS;
use Utopia\Messaging\Adapter\SMS\Mock;
use Utopia\Messaging\Messages\SMS;
use Utopia\Tests\Adapter\Base;
class SMSTest extends Base
{
/**
* @throws \Exception
*/
public function testSendSMS(): void
{
$sender = new Mock('username', 'password');
$message = new SMS(
to: ['+123456789'],
content: 'Test Content',
from: '+987654321'
);
$sender->send($message);
$smsRequest = $this->getLastRequest();
$this->assertSame('http://request-catcher:5000/mock-sms', $smsRequest['url']);
$this->assertSame('Appwrite Mock Message Sender', $smsRequest['headers']['User-Agent']);
$this->assertSame('username', $smsRequest['headers']['X-Username']);
$this->assertSame('password', $smsRequest['headers']['X-Key']);
$this->assertSame('POST', $smsRequest['method']);
$this->assertSame('+987654321', $smsRequest['data']['from']);
$this->assertSame('+123456789', $smsRequest['data']['to']);
$this->assertSame(98, $sender->getCountryCode($smsRequest['data']['from']));
$this->assertSame(1, $sender->getCountryCode($smsRequest['data']['to']));
}
}