TestClassSms::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
1
<?php
2
/**
3
 * Test - class Sms
4
 *
5
 * @package     fwolflib
6
 * @subpackage	class.test
7
 * @copyright   Copyright 2010, Fwolf
8
 * @author      Fwolf <[email protected]>
9
 * @since		2010-11-23
10
 */
11
12
13
// Define like this, so test can run both under eclipse and web alone.
14
// {{{
15
if (! defined('SIMPLE_TEST')) {
16
	define('SIMPLE_TEST', 'simpletest/');
17
	require_once(SIMPLE_TEST . 'autorun.php');
18
}
19
// Then set output encoding
20
//header('Content-Type: text/html; charset=utf-8');
21
// }}}
22
23
// Require library define file which need test
24
require_once('../fwolflib.php');
25
require_once(FWOLFLIB . 'class/adodb.php');
26
require_once(FWOLFLIB . 'class/sms.php');
27
require_once(FWOLFLIB . 'func/request.php');
28
29
30
class TestClassSms extends UnitTestCase {
31
32
	function __construct() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
33
		$ar_db = array(
34
			'type'	=> 'mysqli',
35
			'host'	=> 'localhost',
36
			'user'	=> 't-sms',
37
			'pass'	=> '',
38
			'name'	=> 't-sms',
39
			'lang'	=> 'utf-8',
40
		);
41
		$o_db = new Adodb($ar_db);
0 ignored issues
show
Deprecated Code introduced by
The class Adodb has been deprecated with message: Use Fwlib\Bridge\Adodb

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
42
		$o_db->Connect();
43
		$this->oSms = new Sms($o_db);
0 ignored issues
show
Deprecated Code introduced by
The class Sms has been deprecated with message: Use Fwlib\Net\Sms\SmsSender

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
44
		// Cat of debug sms
45
		$this->iCat = 1020000;
46
	} // end of func __construct
47
48
49
	function TestCountPart () {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
50
		$s_sms = '';	// 0
51
		$this->assertEqual(0, $this->oSms->CountPart($s_sms));
52
		$s_sms = '01234567890123456789012345678901234567890123456789'
53
			. '01234567890123456789012345678901234567890123456789'
54
			. '0123456789012345678901234567890123456789';	// 140
55
		$this->assertEqual(1, $this->oSms->CountPart($s_sms));
56
		$s_sms = '01234567890123456789012345678901234567890123456789'
57
			. '01234567890123456789012345678901234567890123456789
58
01234567890123456789012345678901234567890';	// 141
59
		$this->assertEqual(2, $this->oSms->CountPart($s_sms));
60
61
		$s_sms = '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'
62
			. '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十
63
一二三四五六七八';	// 69
64
		$this->assertEqual(1, $this->oSms->CountPart($s_sms));
65
		$s_sms = '0123456789一二三四五六七八九十一二三四五六七八九十'
66
			. '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'
67
			. '一二三四五六七八九十';	// 70
68
		$this->assertEqual(1, $this->oSms->CountPart($s_sms));
69
		$s_sms = '0123456789一二三四五六七八九十一二三四五六七八九十'
70
			. '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'
71
			. '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'
72
			. '一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十'
73
			. '一二三四五六七八九十一二三四五六七八九十';	// 140
74
		$this->assertEqual(2, $this->oSms->CountPart($s_sms));
75
	} // end of func TestCountPart
76
77
78
    function TestDestParse () {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
79
		$s_dest = "13912345678
80
			13912345678,;
81
			008613912345678 ,\t
82
			13921345678\r\n\t
83
			1392345678\r\n\t
84
			+8613912345678;
85
			+8613912345678,end
86
		";
87
		$ar_dest = array('13912345678', '13921345678');
88
		$this->assertEqual($ar_dest, $this->oSms->DestParse($s_dest));
89
90
		$s_dest = "13012345678,13012345679";
91
		$ar_dest = array('13012345678', '13012345679');
92
		$this->assertEqual($ar_dest, $this->oSms->DestParse($s_dest));
93
    } // end of func TestDestParse
94
95
    function TestSendUsingGammuSmsdInject () {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
96
		$this->oSms->SendUsingGammuSmsdInject('1391234567'
97
			, '测试短信', $this->iCat);
98
    } // end of func TestSendUsingGammuSmsdInject
99
100
} // end of class TestClassSms
101
102
103
// Change output charset in this way.
104
// {{{
105
$s_url = GetSelfUrl(false);
0 ignored issues
show
Deprecated Code introduced by
The function GetSelfUrl() has been deprecated with message: Use Fwlib\Util\HttpUtil::getSelfUrl()

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
106
$s_url = substr($s_url, strrpos($s_url, '/') + 1);
107
if ('sms.test.php' == $s_url) {
108
	$test = new TestClassSms();
109
	$test->run(new HtmlReporter('utf-8'));
110
}
111
// }}}
112
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
113