This repository was archived by the owner on Sep 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
156 lines (132 loc) · 3.95 KB
/
test.php
File metadata and controls
156 lines (132 loc) · 3.95 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
require_once 'ohana.php';
hardReset();
$tests = array(
/*
array(
'mint', 'description',
'type', 'year', 'collection', 'expected accession number',
),
*/
array(
'mint', 'first interview',
'test', '1900', 'a', '1900test001_a001',
),
array(
'mint', 'second interview - same inputs',
'test', '1900', 'a', '1900test002_a002',
),
array(
'mint', 'new type gets its own counters',
'oh', '1900', 'a', '1900oh001_a001',
),
array(
'mint', 'collection and year counters are tracked separately',
'oh', '1900', 'b', '1900oh002_b001',
),
array(
'mint', 'second interview in a collection',
'oh', '1900', 'b', '1900oh003_b002',
),
array(
'mint', 'new year and collection',
'oh', '1901', 'c', '1901oh001_c001',
),
array(
'mint', 'reusing collection and year that had not been used together',
'oh', '1901', 'a', '1901oh002_a002',
),
array(
'mint', 'back to an old collection-year combination',
'oh', '1900', 'a', '1900oh004_a003',
),
/*
array(
'record', 'description',
'accession number', array(expected result),
),
*/
array(
'record', "can't reuse a year counter even if other parts change",
'1900test001_a003', array('error' => 'The year and collection counters cannot be reused.'),
),
array(
'record', 'can record a number that could be minted',
'1902test002_a004', array('canonical' => '1902test002_a004'),
),
array(
'mint', 'minting skips past all used counter values',
'test', '1902', 'a', '1902test003_a005',
),
array(
'record', 'canonicalization works',
'1899 OH/ 151 AB 9 Sess 3', array(
'canonical' => '1899oh151_ab009',
'as_submitted' => '1899 OH/ 151 AB 9 Sess 3',
),
),
array(
'record', '5-digit years are not truncated',
'11902test004_d001', array(
'canonical' => '11902test004_d001',
'as_submitted' => '11902test004_d001',
),
),
array(
'revoke', 'revoking works',
'1902test002_a004', array('circulating' => 0),
),
array(
'revoke', 'revoking twice works',
'1902test002_a004', array('circulating' => 0),
),
array(
'revoke', 'revoking a nonexistent identifier returns an error',
'1900test001_a003', array('error' => 'No such accession number exists.'),
),
array(
'circulate', 'circulating a nonexistent identifier returns an error',
'1900test001_a003', array('error' => 'No such accession number exists.'),
),
array(
'circulate', 'circulating works',
'1899oh151_ab009', array('circulating' => 1),
),
array(
'circulate', 'circulating twice works',
'1899oh151_ab009', array('circulating' => 1),
),
);
foreach ($tests as $test)
{
if ($test[0] === 'mint') {
$description = $test[1];
$options = array(
'type' => $test[2],
'year' => $test[3],
'collection' => $test[4],
);
$expected = array(
'canonical' => $test[5],
);
performMintTest($description, $options, $expected);
}
elseif ($test[0] === 'record') {
$description = $test[1];
$accessionNumber = $test[2];
$expected = $test[3];
performRecordTest($description, $accessionNumber, $expected);
}
elseif ($test[0] === 'revoke') {
$description = $test[1];
$accessionNumber = $test[2];
$expected = $test[3];
performRevokeTest($description, $accessionNumber, $expected);
}
elseif ($test[0] === 'circulate') {
$description = $test[1];
$accessionNumber = $test[2];
$expected = $test[3];
performCirculateTest($description, $accessionNumber, $expected);
}
}