1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/yiiviet/yii2-esms |
4
|
|
|
* @copyright Copyright (c) 2017 Yii Viet |
5
|
|
|
* @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php) |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace yiiviet\tests\unit\esms; |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Lớp ESMSTest |
13
|
|
|
* |
14
|
|
|
* @author Vuong Minh <[email protected]> |
15
|
|
|
* @since 1.0 |
16
|
|
|
*/ |
17
|
|
|
class ESMSTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
public function testBalance() |
21
|
|
|
{ |
22
|
|
|
$data = $this->eSMS->getBalance(); |
23
|
|
|
|
24
|
|
|
if ($this->isConstantsTestDefined()) { |
25
|
|
|
$this->assertTrue($data->isOk); |
|
|
|
|
26
|
|
|
$this->assertGreaterThanOrEqual(0, $data['Balance']); |
27
|
|
|
} else { |
28
|
|
|
$this->assertFalse($data->isOk); |
|
|
|
|
29
|
|
|
$this->assertEquals(0, $data['Balance']); |
30
|
|
|
} |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testSendSMS() |
34
|
|
|
{ |
35
|
|
|
$data = $this->eSMS->sendSMS([ |
36
|
|
|
'Phone' => '0909113911', |
37
|
|
|
'Content' => 'Hweeeeeeeeeeee' |
38
|
|
|
]); |
39
|
|
|
|
40
|
|
|
if ($this->isConstantsTestDefined()) { |
41
|
|
|
$this->assertTrue($data->isOk); |
|
|
|
|
42
|
|
|
} else { |
43
|
|
|
$this->assertFalse($data->isOk); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testGetSendStatus() |
48
|
|
|
{ |
49
|
|
|
$data = $this->eSMS->getSendStatus('b4ce9ecf-d7e1-4878-ab16-5ed696de090312'); |
50
|
|
|
$this->assertFalse($data->isOk); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testGetReceiverStatus() |
54
|
|
|
{ |
55
|
|
|
$data = $this->eSMS->getReceiverStatus('b4ce9ecf-d7e1-4878-ab16-5ed696de090312'); |
56
|
|
|
$this->assertFalse($data->isOk); |
|
|
|
|
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testSendVoiceCall() |
60
|
|
|
{ |
61
|
|
|
$data = $this->eSMS->sendVoice([ |
62
|
|
|
'Phone' => '0909113911', |
63
|
|
|
'ApiCode' => '96cd1977-dc4e-48d5-8ef9-cd4837840250', |
64
|
|
|
'PassCode' => '96cd1977-dc4e-48d5-8ef9-cd4837840250' |
65
|
|
|
]); |
66
|
|
|
|
67
|
|
|
if ($this->isConstantsTestDefined()) { |
68
|
|
|
$this->assertTrue($data->isOk); |
|
|
|
|
69
|
|
|
} else { |
70
|
|
|
$this->assertFalse($data->isOk); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
} |
75
|
|
|
|
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: