-
Notifications
You must be signed in to change notification settings - Fork 88
/
ParcelTest.php
69 lines (62 loc) · 1.79 KB
/
ParcelTest.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
<?php
class Shippo_ParcelTest extends TestCase
{
public function testValidCreate()
{
$parcel = self::getDefaultParcel();
$this->assertEquals($parcel->object_state, 'VALID');
}
public function testInvalidCreate()
{
try {
$parcel = Shippo_Parcel::create(array(
'invalid_data' => 'invalid'
));
}
catch (Exception $e) {
$this->assertTrue(true);
}
}
public function testRetrieve()
{
$parcel = self::getDefaultParcel();
$retrieve_parcel = Shippo_Parcel::retrieve($parcel->object_id);
$this->assertEquals($retrieve_parcel->object_id, $parcel->object_id);
}
public function testInvalidRetrieve()
{
$parcel = self::getDefaultParcel();
$retrieve_parcel = Shippo_Parcel::retrieve($parcel->object_id);
$this->assertNotEquals($retrieve_parcel->object_id, 'Invalid Value');
}
public function testListAll()
{
$list = Shippo_Parcel::all(array(
'results' => '3',
'page' => '1'
));
$this->assertFalse(is_null($list->results));
}
public function testListPageSize()
{
$pagesize = 1;
$list = Shippo_Parcel::all(array(
'results' => $pagesize,
'page' => '1'
));
$this->assertEquals(count($list->results), $pagesize);
}
public static function getDefaultParcel()
{
return Shippo_Parcel::create(array(
'length' => '5',
'width' => '5',
'height' => '5',
'distance_unit' => 'cm',
'weight' => '2',
'mass_unit' => 'lb',
'template' => '',
'metadata' => 'Customer ID 123456'
));
}
}