This repository has been archived by the owner on Aug 19, 2019. It is now read-only.
/
NormalTest.php
73 lines (63 loc) · 1.94 KB
/
NormalTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
use JustMd5\Express\Express;
/**
* Created for express.
* File: NormalTest.php
* User: ding21st@gmail.com
* Date: 16/4/18
* Time: 下午4:09.
*/
class NormalTest extends PHPUnit_Framework_TestCase
{
/**
* @return string
*/
public function testExpressNameJsonCheck()
{
$this->assertJson(Express::getExpressName(719296993609));
return '719296993609';
}
/**
* @depends testExpressNameJsonCheck
*/
public function testExpressInfoJsonCheck($ExpressNumber)
{
$ExpressInfo = Express::getExpressInfo($ExpressNumber);
$this->assertJson($ExpressInfo);
return $ExpressInfo;
}
/**
* @depends testExpressInfoJsonCheck
*/
public function testHasInfoData($ExpressInfo)
{
$InfoJsonString = $ExpressInfo;
$InfoJsonObject = json_decode($InfoJsonString);
if (is_object($InfoJsonObject)) {
$this->assertObjectHasAttribute('message', $InfoJsonObject, '对象中不包含message属性');
$this->assertObjectHasAttribute('data', $InfoJsonObject, '对象中不包含data属性');
$this->assertObjectHasAttribute('ischeck', $InfoJsonObject, '对象中不包含ischeck属性');
$this->assertObjectHasAttribute('status', $InfoJsonObject, '对象中不包含status属性');
}
return $InfoJsonObject;
}
/**
* @depends testHasInfoData
*
* @param $InfoJsonObject
*/
public function testIsStatusOk($InfoJsonObject)
{
$this->assertEquals('200', $InfoJsonObject->status);
return $InfoJsonObject;
}
/**
* @depends testIsStatusOk
*/
public function testDataInfo($InfoJsonObject)
{
$InfoArray = json_decode(json_encode($InfoJsonObject), true);
$this->assertArrayHasKey('data', $InfoArray, '数组中data信息不存在');
$this->assertNotEmpty($InfoArray['data'], '快递信息为空');
}
}