Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl; |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
use Test::More tests => 3; |
5 |
|
6 |
use C4::Context; |
7 |
use C4::Utils::DataTables::ColumnsSettings; |
8 |
my $dbh = C4::Context->dbh; |
9 |
$dbh->{AutoCommit} = 0; |
10 |
$dbh->{RaiseError} = 1; |
11 |
|
12 |
$dbh->do(q|DELETE FROM columns_settings|); |
13 |
|
14 |
C4::Utils::DataTables::ColumnsSettings::update_columns( |
15 |
{ |
16 |
columns => [ |
17 |
{ |
18 |
module => 'circ', |
19 |
page => 'circulation', |
20 |
tablename => 'holdst', |
21 |
columnname => 'barcode', |
22 |
is_hidden => 1, |
23 |
cannot_be_toggled => 1 |
24 |
}, |
25 |
{ |
26 |
module => 'circ', |
27 |
page => 'circulation', |
28 |
tablename => 'holdst', |
29 |
columnname => 'call_number', |
30 |
is_hidden => 0, |
31 |
cannot_be_toggled => 1 |
32 |
}, |
33 |
{ |
34 |
module => 'circ', |
35 |
page => 'circulation', |
36 |
tablename => 'holdst', |
37 |
columnname => 'delete', |
38 |
is_hidden => 1, |
39 |
cannot_be_toggled => 0 |
40 |
}, |
41 |
{ |
42 |
module => 'circ', |
43 |
page => 'circulation', |
44 |
tablename => 'holdst', |
45 |
columnname => 'hold_date', |
46 |
is_hidden => 1, |
47 |
cannot_be_toggled => 0 |
48 |
}, |
49 |
{ |
50 |
module => 'circ', |
51 |
page => 'circulation', |
52 |
tablename => 'holdst', |
53 |
columnname => 'info', |
54 |
is_hidden => 1, |
55 |
cannot_be_toggled => 0 |
56 |
}, |
57 |
{ |
58 |
module => 'circ', |
59 |
page => 'circulation', |
60 |
tablename => 'holdst', |
61 |
columnname => 'priority', |
62 |
is_hidden => 0, |
63 |
cannot_be_toggled => 0 |
64 |
}, |
65 |
{ |
66 |
module => 'circ', |
67 |
page => 'circulation', |
68 |
tablename => 'holdst', |
69 |
columnname => 'title', |
70 |
is_hidden => 0, |
71 |
cannot_be_toggled => 1 |
72 |
}, |
73 |
{ |
74 |
module => 'circ', |
75 |
page => 'circulation', |
76 |
tablename => 'issuest', |
77 |
columnname => 'call_no', |
78 |
is_hidden => 0, |
79 |
cannot_be_toggled => 0 |
80 |
}, |
81 |
{ |
82 |
module => 'circ', |
83 |
page => 'circulation', |
84 |
tablename => 'issuest', |
85 |
columnname => 'charge', |
86 |
is_hidden => 1, |
87 |
cannot_be_toggled => 0 |
88 |
}, |
89 |
{ |
90 |
module => 'circ', |
91 |
page => 'circulation', |
92 |
tablename => 'issuest', |
93 |
columnname => 'checked_out_from', |
94 |
is_hidden => 0, |
95 |
cannot_be_toggled => 0 |
96 |
}, |
97 |
{ |
98 |
module => 'circ', |
99 |
page => 'circulation', |
100 |
tablename => 'issuest', |
101 |
columnname => 'checked_out_on', |
102 |
is_hidden => 0, |
103 |
cannot_be_toggled => 0 |
104 |
}, |
105 |
{ |
106 |
module => 'circ', |
107 |
page => 'circulation', |
108 |
tablename => 'issuest', |
109 |
columnname => 'check_in', |
110 |
is_hidden => 1, |
111 |
cannot_be_toggled => 0 |
112 |
}, |
113 |
{ |
114 |
module => 'circ', |
115 |
page => 'circulation', |
116 |
tablename => 'issuest', |
117 |
columnname => 'due_date', |
118 |
is_hidden => 0, |
119 |
cannot_be_toggled => 0 |
120 |
}, |
121 |
{ |
122 |
module => 'circ', |
123 |
page => 'circulation', |
124 |
tablename => 'issuest', |
125 |
columnname => 'export', |
126 |
is_hidden => 1, |
127 |
cannot_be_toggled => 0 |
128 |
}, |
129 |
{ |
130 |
module => 'circ', |
131 |
page => 'circulation', |
132 |
tablename => 'issuest', |
133 |
columnname => 'item_type', |
134 |
is_hidden => 0, |
135 |
cannot_be_toggled => 0 |
136 |
}, |
137 |
{ |
138 |
module => 'circ', |
139 |
page => 'circulation', |
140 |
tablename => 'issuest', |
141 |
columnname => 'price', |
142 |
is_hidden => 1, |
143 |
cannot_be_toggled => 1 |
144 |
}, |
145 |
{ |
146 |
module => 'circ', |
147 |
page => 'circulation', |
148 |
tablename => 'issuest', |
149 |
columnname => 'renew', |
150 |
is_hidden => 1, |
151 |
cannot_be_toggled => 0 |
152 |
}, |
153 |
{ |
154 |
module => 'circ', |
155 |
page => 'circulation', |
156 |
tablename => 'issuest', |
157 |
columnname => 'title', |
158 |
is_hidden => 0, |
159 |
cannot_be_toggled => 1 |
160 |
}, |
161 |
] |
162 |
} |
163 |
); |
164 |
|
165 |
my $modules = C4::Utils::DataTables::ColumnsSettings::get_modules(); |
166 |
|
167 |
my $modules_expected = { |
168 |
'circ' => { |
169 |
'circulation' => { |
170 |
'holdst' => [ |
171 |
{ |
172 |
'columnname' => 'hold_date', |
173 |
'is_hidden' => '1', |
174 |
'cannot_be_toggled' => '0' |
175 |
}, |
176 |
{ |
177 |
'columnname' => 'title', |
178 |
'is_hidden' => '0', |
179 |
'cannot_be_toggled' => '1' |
180 |
}, |
181 |
{ |
182 |
'columnname' => 'call_number', |
183 |
'is_hidden' => '0', |
184 |
'cannot_be_toggled' => '1' |
185 |
}, |
186 |
{ |
187 |
'columnname' => 'barcode', |
188 |
'is_hidden' => '1', |
189 |
'cannot_be_toggled' => '1' |
190 |
}, |
191 |
{ |
192 |
'columnname' => 'priority', |
193 |
'is_hidden' => '0', |
194 |
'cannot_be_toggled' => '0' |
195 |
}, |
196 |
{ |
197 |
'columnname' => 'delete', |
198 |
'is_hidden' => '1', |
199 |
'cannot_be_modified' => '1', |
200 |
'cannot_be_toggled' => '0' |
201 |
}, |
202 |
{ |
203 |
'columnname' => 'info', |
204 |
'is_hidden' => '1', |
205 |
'cannot_be_modified' => '1', |
206 |
'cannot_be_toggled' => '0' |
207 |
} |
208 |
], |
209 |
'issuest' => [ |
210 |
{ |
211 |
'columnname' => 'due_date', |
212 |
'is_hidden' => '0', |
213 |
'cannot_be_toggled' => '0' |
214 |
}, |
215 |
{ |
216 |
'columnname' => 'title', |
217 |
'is_hidden' => '0', |
218 |
'cannot_be_toggled' => '1' |
219 |
}, |
220 |
{ |
221 |
'columnname' => 'item_type', |
222 |
'is_hidden' => '0', |
223 |
'cannot_be_toggled' => '0' |
224 |
}, |
225 |
{ |
226 |
'columnname' => 'checked_out_on', |
227 |
'is_hidden' => '0', |
228 |
'cannot_be_toggled' => '0' |
229 |
}, |
230 |
{ |
231 |
'columnname' => 'checked_out_from', |
232 |
'is_hidden' => '0', |
233 |
'cannot_be_toggled' => '0' |
234 |
}, |
235 |
{ |
236 |
'columnname' => 'call_no', |
237 |
'is_hidden' => '0', |
238 |
'cannot_be_toggled' => '0' |
239 |
}, |
240 |
{ |
241 |
'columnname' => 'charge', |
242 |
'is_hidden' => '1', |
243 |
'cannot_be_toggled' => '0' |
244 |
}, |
245 |
{ |
246 |
'columnname' => 'price', |
247 |
'is_hidden' => '1', |
248 |
'cannot_be_toggled' => '1' |
249 |
}, |
250 |
{ |
251 |
'columnname' => 'renew', |
252 |
'is_hidden' => '1', |
253 |
'cannot_be_modified' => '1', |
254 |
'cannot_be_toggled' => '0' |
255 |
}, |
256 |
{ |
257 |
'columnname' => 'check_in', |
258 |
'is_hidden' => '1', |
259 |
'cannot_be_modified' => '1', |
260 |
'cannot_be_toggled' => '0' |
261 |
}, |
262 |
{ |
263 |
'columnname' => 'export', |
264 |
'is_hidden' => '1', |
265 |
'cannot_be_modified' => '1', |
266 |
'cannot_be_toggled' => '0' |
267 |
} |
268 |
] |
269 |
} |
270 |
} |
271 |
}; |
272 |
|
273 |
is_deeply( $modules, $modules_expected, 'get_modules returns all values' ); |
274 |
|
275 |
for my $m ( keys %$modules ) { |
276 |
for my $p ( keys %{ $modules->{$m} } ) { |
277 |
for my $t ( keys %{ $modules->{$m}{$p} } ) { |
278 |
my $columns = |
279 |
C4::Utils::DataTables::ColumnsSettings::get_columns( $m, $p, $t ); |
280 |
is_deeply( |
281 |
$columns, |
282 |
$modules->{$m}{$p}{$t}, |
283 |
"columns for $m>$p>$t" |
284 |
); |
285 |
} |
286 |
} |
287 |
} |
288 |
|
289 |
$dbh->rollback; |