Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
namespace smsgateway_aws;
18
 
19
use core_sms\message;
20
 
21
/**
22
 * AWS SMS gateway tests.
23
 *
24
 * @package    smsgateway_aws
25
 * @category   test
26
 * @copyright  2024 Safat Shahin <safat.shahin@moodle.com>
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 * @covers     \smsgateway_aws\gateway
29
 */
30
final class gateway_test extends \advanced_testcase {
31
 
32
    public function test_update_message_status(): void {
33
        $this->resetAfterTest();
34
 
35
        $config = new \stdClass();
36
        $config->api_key = 'test_api_key';
37
 
38
        $manager = \core\di::get(\core_sms\manager::class);
39
        $gw = $manager->create_gateway_instance(
40
            classname: gateway::class,
41
            name: 'aws',
42
            enabled: true,
43
            config: $config,
44
        );
45
        $othergw = $manager->create_gateway_instance(
46
            classname: gateway::class,
47
            name: 'aws',
48
            enabled: true,
49
            config: $config,
50
        );
51
 
52
        $message = new message(
53
            recipientnumber: '1234567890',
54
            content: 'Hello, world!',
55
            component: 'smsgateway_aws',
56
            messagetype: 'test',
57
            recipientuserid: null,
58
            issensitive: false,
59
            gatewayid: $gw->id,
60
        );
61
        $message2 = new message(
62
            recipientnumber: '1234567890',
63
            content: 'Hello, world!',
64
            component: 'smsgateway_aws',
65
            messagetype: 'test',
66
            recipientuserid: null,
67
            issensitive: false,
68
            gatewayid: $gw->id,
69
        );
70
 
71
        $updatedmessages = $gw->update_message_statuses([$message, $message2]);
72
        $this->assertEquals([$message, $message2], $updatedmessages);
73
 
74
        $this->expectException(\coding_exception::class);
75
        $othergw->update_message_status($message);
76
    }
77
}