Completed
Push — master ( dace01...7478f6 )
by Keal
02:47
created

SmsTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 7
c 3
b 0
f 2
lcom 1
cbo 2
dl 0
loc 64
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Odeen
5
 * Date: 2016/6/12
6
 * Time: 10:11.
7
 */
8
namespace Sms\Test;
9
10
use LaravelSms\sms\Sms;
11
use PHPUnit_Framework_TestCase;
12
13
class SmsTest extends PHPUnit_Framework_TestCase
14
{
15
    protected $sms = null;
16
17
    public function setUp()
18
    {
19
        $config = 'YunTongXun';
20
        $this->sms = new Sms($config);
21
    }
22
23
    public function testGetSmsData()
24
    {
25
        $data = $this->sms->getData();
26
        $this->assertArrayHasKey('to', $data);
27
        $this->assertArrayHasKey('templates', $data);
28
        $this->assertArrayHasKey('templateData', $data);
29
        $this->assertArrayHasKey('content', $data);
30
        $this->sms->to('...');
31
        $this->assertEquals('...', $this->sms->getData('to'));
32
    }
33
34
    public function smsData()
35
    {
36
        return $this->sms->getData();
37
    }
38
39
    public function testSetTo()
40
    {
41
        $this->sms->to('123456...');
42
        $smsData = $this->smsData();
43
        $this->assertEquals('123456...', $smsData['to']);
44
    }
45
46
    public function testSetContent()
47
    {
48
        $this->sms->content('this is content');
49
        $smsData = $this->smsData();
50
        $this->assertEquals('this is content', $smsData['content']);
51
    }
52
53
    public function testSetTemplate()
54
    {
55
        $this->sms->template('foo', '111');
56
        $smsData = $this->smsData();
57
        $this->assertEquals(['foo' => '111'], $smsData['templates']);
58
59
        $this->sms->template(['foo' => '111', 'bar' => '222']);
60
        $smsData = $this->smsData();
61
        $this->assertEquals(['foo' => '111', 'bar' => '222'], $smsData['templates']);
62
    }
63
64
    public function testSetData()
65
    {
66
        $this->sms->data([
67
            'code' => '1',
68
            'msg'  => 'msg',
69
        ]);
70
        $smsData = $this->smsData();
71
        $this->assertEquals([
72
            'code' => '1',
73
            'msg'  => 'msg',
74
        ], $smsData['templateData']);
75
    }
76
}
77