ESMSTest::testSendVoiceCall()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.7998
c 0
b 0
f 0
cc 2
nc 2
nop 0
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);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
26
            $this->assertGreaterThanOrEqual(0, $data['Balance']);
27
        } else {
28
            $this->assertFalse($data->isOk);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
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);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
42
        } else {
43
            $this->assertFalse($data->isOk);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
44
        }
45
    }
46
47
    public function testGetSendStatus()
48
    {
49
        $data = $this->eSMS->getSendStatus('b4ce9ecf-d7e1-4878-ab16-5ed696de090312');
50
        $this->assertFalse($data->isOk);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
51
    }
52
53
    public function testGetReceiverStatus()
54
    {
55
        $data = $this->eSMS->getReceiverStatus('b4ce9ecf-d7e1-4878-ab16-5ed696de090312');
56
        $this->assertFalse($data->isOk);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
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);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
69
        } else {
70
            $this->assertFalse($data->isOk);
0 ignored issues
show
Bug introduced by
Accessing isOk on the interface GatewayClients\DataInterface suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
71
        }
72
    }
73
74
}
75