-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_bill_array.php
More file actions
99 lines (85 loc) · 2.48 KB
/
test_bill_array.php
File metadata and controls
99 lines (85 loc) · 2.48 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
require_once 'php/log.php';
require_once 'php/orm_bill.php';
header("Content-Type: text/plain");
$tests = 0;
$success = 0;
//--------------------------------------
echo "[TEST] Creating a Bill from an array without financial info\r\n";
$pre_arr = array(
'title' => 'Bi-Partisan Cheese Act of 2016',
'code' => 'H.R. 42',
'summary' => 'Provides for new types of cheese',
'committee' => 'Cheese Committee',
'cbo_url' => 'http://example.com/cbo/cheese',
'pdf_url' => 'http://example.com/cbo/cheese.pdf',
'published' => '2016-12-25'
);
$bill = Bill::from_array($pre_arr);
$post_arr = $bill->to_array();
$tests++;
if ($pre_arr == $post_arr) {
$success++;
echo "[SUCCESS]\r\n";
} else {
echo "[FAILURE] Input array and Bill::to_array were not equal\r\n";
echo "[EXPECTED]\r\n";
print_r($pre_arr);
echo "[RECEIVED]\r\n";
print_r($post_arr);
}
//--------------------------------------
echo "[TEST] Creating a Bill from an array with financial info\r\n";
$pre_arr = array(
'title' => 'Bi-Partisan Cheese Act of 2016',
'code' => 'H.R. 42',
'summary' => 'Provides for new types of cheese',
'committee' => 'Cheese Committee',
'cbo_url' => 'http://example.com/cbo/cheese',
'pdf_url' => 'http://example.com/cbo/cheese.pdf',
'published' => '2016-12-25',
'finances' => array(
array(
'amount' => -5000,
'timespan' => 1,
),
array(
'amount' => 10000,
'timespan' => 5,
)
)
);
$bill = Bill::from_array($pre_arr);
$post_arr = $bill->to_array();
$tests++;
if ($pre_arr == $post_arr) {
$success++;
echo "[SUCCESS]\r\n";
} else {
echo "[FAILURE] Input array and Bill::to_array were not equal\r\n";
echo "[EXPECTED]\r\n";
print_r($pre_arr);
echo "[RECEIVED]\r\n";
print_r($post_arr);
}
//--------------------------------------
echo "[TEST] Creating a Bill from a mistyped array\r\n";
$pre_arr = array(
'title' => 'Bi-Partisan Cheese Act of 2016',
'code' => 42,
'summary' => 'Provides for new types of cheese',
'committee' => 'Cheese Committee',
'cbo_url' => 'http://example.com/cbo/cheese',
'pdf_url' => 'http://example.com/cbo/cheese.pdf',
'published' => '2016-12-25'
);
$bill = Bill::from_array($pre_arr);
$tests++;
if ($bill === null) {
$success++;
echo "[SUCCESS]\r\n";
} else {
echo "[FAILURE] Bill::from_array accepted bogus input\r\n";
echo "[RECEIVED]\r\n";
print_r($bill->to_array());
}