1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* COPS (Calibre OPDS PHP Server) test file |
4
|
|
|
* |
5
|
|
|
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) |
6
|
|
|
* @author Sébastien Lucas <[email protected]> |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
require_once(dirname(__FILE__) . "/config_test.php"); |
10
|
|
|
require_once(dirname(__FILE__) . "/../book.php"); |
11
|
|
|
require_once (dirname(__FILE__) . "/../JSON_renderer.php"); |
12
|
|
|
|
13
|
|
|
class CustomColumnTest extends PHPUnit_Framework_TestCase |
14
|
|
|
{ |
15
|
|
|
public function testColumnType01() |
16
|
|
|
{ |
17
|
|
|
global $config; |
18
|
|
|
|
19
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
20
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01"); |
21
|
|
|
Base::clearDb(); |
22
|
|
|
|
23
|
|
|
$coltype = CustomColumnType::createByCustomID(8); |
24
|
|
|
|
25
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_01")); |
26
|
|
|
|
27
|
|
|
$this->assertEquals(8, $coltype->customId); |
28
|
|
|
$this->assertEquals("custom_01", $coltype->columnTitle); |
29
|
|
|
$this->assertEquals("text", $coltype->datatype); |
30
|
|
|
$this->assertEquals("CustomColumnTypeText", get_class($coltype)); |
31
|
|
|
|
32
|
|
|
$this->assertCount(3, $coltype->getAllCustomValues()); |
33
|
|
|
$this->assertEquals("?page=14&custom=8", $coltype->getUriAllCustoms()); |
34
|
|
|
$this->assertEquals("cops:custom:8", $coltype->getAllCustomsId()); |
35
|
|
|
$this->assertEquals("custom_01", $coltype->getTitle()); |
36
|
|
|
$this->assertEquals("Custom column example 01 (text)", $coltype->getDatabaseDescription()); |
37
|
|
|
$this->assertEquals("Custom column example 01 (text)", $coltype->getDescription()); |
38
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
39
|
|
|
|
40
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
41
|
|
|
$config['cops_calibre_custom_column'] = array(); |
42
|
|
|
Base::clearDb(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testColumnType01b() |
46
|
|
|
{ |
47
|
|
|
global $config; |
48
|
|
|
|
49
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
50
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01b"); |
51
|
|
|
Base::clearDb(); |
52
|
|
|
|
53
|
|
|
$coltype = CustomColumnType::createByCustomID(16); |
54
|
|
|
|
55
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_01b")); |
56
|
|
|
|
57
|
|
|
$this->assertEquals(16, $coltype->customId); |
58
|
|
|
$this->assertEquals("custom_01b", $coltype->columnTitle); |
59
|
|
|
$this->assertEquals("text", $coltype->datatype); |
60
|
|
|
$this->assertEquals("CustomColumnTypeText", get_class($coltype)); |
61
|
|
|
|
62
|
|
|
$this->assertCount(3, $coltype->getAllCustomValues()); |
63
|
|
|
$this->assertEquals("?page=14&custom=16", $coltype->getUriAllCustoms()); |
64
|
|
|
$this->assertEquals("cops:custom:16", $coltype->getAllCustomsId()); |
65
|
|
|
$this->assertEquals("custom_01b", $coltype->getTitle()); |
66
|
|
|
$this->assertEquals(NULL, $coltype->getDatabaseDescription()); |
67
|
|
|
$this->assertEquals("Custom column 'custom_01b'", $coltype->getDescription()); |
68
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
69
|
|
|
|
70
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
71
|
|
|
$config['cops_calibre_custom_column'] = array(); |
72
|
|
|
Base::clearDb(); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function testColumnType02() |
76
|
|
|
{ |
77
|
|
|
global $config; |
78
|
|
|
|
79
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
80
|
|
|
$config['cops_calibre_custom_column'] = array("custom_02"); |
81
|
|
|
Base::clearDb(); |
82
|
|
|
|
83
|
|
|
$coltype = CustomColumnType::createByCustomID(6); |
84
|
|
|
|
85
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_02")); |
86
|
|
|
|
87
|
|
|
$this->assertEquals(6, $coltype->customId); |
88
|
|
|
$this->assertEquals("custom_02", $coltype->columnTitle); |
89
|
|
|
$this->assertEquals("text", $coltype->datatype); |
90
|
|
|
$this->assertEquals("CustomColumnTypeText", get_class($coltype)); |
91
|
|
|
|
92
|
|
|
$this->assertCount(3, $coltype->getAllCustomValues()); |
93
|
|
|
$this->assertEquals("?page=14&custom=6", $coltype->getUriAllCustoms()); |
94
|
|
|
$this->assertEquals("cops:custom:6", $coltype->getAllCustomsId()); |
95
|
|
|
$this->assertEquals("custom_02", $coltype->getTitle()); |
96
|
|
|
$this->assertEquals("Custom column example 02 (csv)", $coltype->getDatabaseDescription()); |
97
|
|
|
$this->assertEquals("Custom column example 02 (csv)", $coltype->getDescription()); |
98
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
99
|
|
|
|
100
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
101
|
|
|
$config['cops_calibre_custom_column'] = array(); |
102
|
|
|
Base::clearDb(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function testColumnType03() |
106
|
|
|
{ |
107
|
|
|
global $config; |
108
|
|
|
|
109
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
110
|
|
|
$config['cops_calibre_custom_column'] = array("custom_03"); |
111
|
|
|
Base::clearDb(); |
112
|
|
|
|
113
|
|
|
$coltype = CustomColumnType::createByCustomID(7); |
114
|
|
|
|
115
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_03")); |
116
|
|
|
|
117
|
|
|
$this->assertEquals(7, $coltype->customId); |
118
|
|
|
$this->assertEquals("custom_03", $coltype->columnTitle); |
119
|
|
|
$this->assertEquals("comments", $coltype->datatype); |
120
|
|
|
$this->assertEquals("CustomColumnTypeComment", get_class($coltype)); |
121
|
|
|
|
122
|
|
|
$this->assertEquals("?page=14&custom=7", $coltype->getUriAllCustoms()); |
123
|
|
|
$this->assertEquals("cops:custom:7", $coltype->getAllCustomsId()); |
124
|
|
|
$this->assertEquals("custom_03", $coltype->getTitle()); |
125
|
|
|
$this->assertEquals("Custom column example 03 (long_text)", $coltype->getDatabaseDescription()); |
126
|
|
|
$this->assertEquals("Custom column example 03 (long_text)", $coltype->getDescription()); |
127
|
|
|
$this->assertEquals(false, $coltype->isSearchable()); |
128
|
|
|
|
129
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
130
|
|
|
$config['cops_calibre_custom_column'] = array(); |
131
|
|
|
Base::clearDb(); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
public function testColumnType04() |
135
|
|
|
{ |
136
|
|
|
global $config; |
137
|
|
|
|
138
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
139
|
|
|
$config['cops_calibre_custom_column'] = array("custom_04"); |
140
|
|
|
Base::clearDb(); |
141
|
|
|
|
142
|
|
|
$coltype = CustomColumnType::createByCustomID(4); |
143
|
|
|
|
144
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_04")); |
145
|
|
|
|
146
|
|
|
$this->assertEquals(4, $coltype->customId); |
147
|
|
|
$this->assertEquals("custom_04", $coltype->columnTitle); |
148
|
|
|
$this->assertEquals("series", $coltype->datatype); |
149
|
|
|
$this->assertEquals("CustomColumnTypeSeries", get_class($coltype)); |
150
|
|
|
|
151
|
|
|
$this->assertCount(3, $coltype->getAllCustomValues()); |
152
|
|
|
$this->assertEquals("?page=14&custom=4", $coltype->getUriAllCustoms()); |
153
|
|
|
$this->assertEquals("cops:custom:4", $coltype->getAllCustomsId()); |
154
|
|
|
$this->assertEquals("custom_04", $coltype->getTitle()); |
155
|
|
|
$this->assertEquals("Custom column example 04 (series_text)", $coltype->getDatabaseDescription()); |
156
|
|
|
$this->assertEquals("Alphabetical index of the 3 series", $coltype->getDescription()); |
157
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
158
|
|
|
|
159
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
160
|
|
|
$config['cops_calibre_custom_column'] = array(); |
161
|
|
|
Base::clearDb(); |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
public function testColumnType05() |
165
|
|
|
{ |
166
|
|
|
global $config; |
167
|
|
|
|
168
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
169
|
|
|
$config['cops_calibre_custom_column'] = array("custom_05"); |
170
|
|
|
Base::clearDb(); |
171
|
|
|
|
172
|
|
|
$coltype = CustomColumnType::createByCustomID(5); |
173
|
|
|
|
174
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_05")); |
175
|
|
|
|
176
|
|
|
$this->assertEquals(5, $coltype->customId); |
177
|
|
|
$this->assertEquals("custom_05", $coltype->columnTitle); |
178
|
|
|
$this->assertEquals("enumeration", $coltype->datatype); |
179
|
|
|
$this->assertEquals("CustomColumnTypeEnumeration", get_class($coltype)); |
180
|
|
|
|
181
|
|
|
$this->assertCount(4, $coltype->getAllCustomValues()); |
182
|
|
|
$this->assertEquals("?page=14&custom=5", $coltype->getUriAllCustoms()); |
183
|
|
|
$this->assertEquals("cops:custom:5", $coltype->getAllCustomsId()); |
184
|
|
|
$this->assertEquals("custom_05", $coltype->getTitle()); |
185
|
|
|
$this->assertEquals("Custom column example 05 (enum)", $coltype->getDatabaseDescription()); |
186
|
|
|
$this->assertEquals("Alphabetical index of the 4 values", $coltype->getDescription()); |
187
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
188
|
|
|
|
189
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
190
|
|
|
$config['cops_calibre_custom_column'] = array(); |
191
|
|
|
Base::clearDb(); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
public function testColumnType06() |
195
|
|
|
{ |
196
|
|
|
global $config; |
197
|
|
|
|
198
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
199
|
|
|
$config['cops_calibre_custom_column'] = array("custom_06"); |
200
|
|
|
Base::clearDb(); |
201
|
|
|
|
202
|
|
|
$coltype = CustomColumnType::createByCustomID(12); |
203
|
|
|
|
204
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_06")); |
205
|
|
|
|
206
|
|
|
$this->assertEquals(12, $coltype->customId); |
207
|
|
|
$this->assertEquals("custom_06", $coltype->columnTitle); |
208
|
|
|
$this->assertEquals("datetime", $coltype->datatype); |
209
|
|
|
$this->assertEquals("CustomColumnTypeDate", get_class($coltype)); |
210
|
|
|
|
211
|
|
|
$this->assertCount(5, $coltype->getAllCustomValues()); |
212
|
|
|
$this->assertEquals("?page=14&custom=12", $coltype->getUriAllCustoms()); |
213
|
|
|
$this->assertEquals("cops:custom:12", $coltype->getAllCustomsId()); |
214
|
|
|
$this->assertEquals("custom_06", $coltype->getTitle()); |
215
|
|
|
$this->assertEquals("Custom column example 06 (date)", $coltype->getDatabaseDescription()); |
216
|
|
|
$this->assertEquals("Custom column example 06 (date)", $coltype->getDescription()); |
217
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
218
|
|
|
|
219
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
220
|
|
|
$config['cops_calibre_custom_column'] = array(); |
221
|
|
|
Base::clearDb(); |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
public function testColumnType07() |
225
|
|
|
{ |
226
|
|
|
global $config; |
227
|
|
|
|
228
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
229
|
|
|
$config['cops_calibre_custom_column'] = array("custom_07"); |
230
|
|
|
Base::clearDb(); |
231
|
|
|
|
232
|
|
|
$coltype = CustomColumnType::createByCustomID(14); |
233
|
|
|
|
234
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_07")); |
235
|
|
|
|
236
|
|
|
$this->assertEquals(14, $coltype->customId); |
237
|
|
|
$this->assertEquals("custom_07", $coltype->columnTitle); |
238
|
|
|
$this->assertEquals("float", $coltype->datatype); |
239
|
|
|
$this->assertEquals("CustomColumnTypeFloat", get_class($coltype)); |
240
|
|
|
|
241
|
|
|
$this->assertCount(6, $coltype->getAllCustomValues()); |
242
|
|
|
$this->assertEquals("?page=14&custom=14", $coltype->getUriAllCustoms()); |
243
|
|
|
$this->assertEquals("cops:custom:14", $coltype->getAllCustomsId()); |
244
|
|
|
$this->assertEquals("custom_07", $coltype->getTitle()); |
245
|
|
|
$this->assertEquals("Custom column example 07 (float)", $coltype->getDatabaseDescription()); |
246
|
|
|
$this->assertEquals("Custom column example 07 (float)", $coltype->getDescription()); |
247
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
248
|
|
|
|
249
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
250
|
|
|
$config['cops_calibre_custom_column'] = array(); |
251
|
|
|
Base::clearDb(); |
252
|
|
|
} |
253
|
|
|
|
254
|
|
|
public function testColumnType08() |
255
|
|
|
{ |
256
|
|
|
global $config; |
257
|
|
|
|
258
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
259
|
|
|
$config['cops_calibre_custom_column'] = array("custom_08"); |
260
|
|
|
Base::clearDb(); |
261
|
|
|
|
262
|
|
|
$coltype = CustomColumnType::createByCustomID(10); |
263
|
|
|
|
264
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_08")); |
265
|
|
|
|
266
|
|
|
$this->assertEquals(10, $coltype->customId); |
267
|
|
|
$this->assertEquals("custom_08", $coltype->columnTitle); |
268
|
|
|
$this->assertEquals("int", $coltype->datatype); |
269
|
|
|
$this->assertEquals("CustomColumnTypeInteger", get_class($coltype)); |
270
|
|
|
|
271
|
|
|
$this->assertCount(4, $coltype->getAllCustomValues()); |
272
|
|
|
$this->assertEquals("?page=14&custom=10", $coltype->getUriAllCustoms()); |
273
|
|
|
$this->assertEquals("cops:custom:10", $coltype->getAllCustomsId()); |
274
|
|
|
$this->assertEquals("custom_08", $coltype->getTitle()); |
275
|
|
|
$this->assertEquals("Custom column example 08 (int)", $coltype->getDatabaseDescription()); |
276
|
|
|
$this->assertEquals("Custom column example 08 (int)", $coltype->getDescription()); |
277
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
278
|
|
|
|
279
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
280
|
|
|
$config['cops_calibre_custom_column'] = array(); |
281
|
|
|
Base::clearDb(); |
282
|
|
|
} |
283
|
|
|
|
284
|
|
|
public function testColumnType09() |
285
|
|
|
{ |
286
|
|
|
global $config; |
287
|
|
|
|
288
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
289
|
|
|
$config['cops_calibre_custom_column'] = array("custom_09"); |
290
|
|
|
Base::clearDb(); |
291
|
|
|
|
292
|
|
|
$coltype = CustomColumnType::createByCustomID(9); |
293
|
|
|
|
294
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_09")); |
295
|
|
|
|
296
|
|
|
$this->assertEquals(9, $coltype->customId); |
297
|
|
|
$this->assertEquals("custom_09", $coltype->columnTitle); |
298
|
|
|
$this->assertEquals("rating", $coltype->datatype); |
299
|
|
|
$this->assertEquals("CustomColumnTypeRating", get_class($coltype)); |
300
|
|
|
|
301
|
|
|
$this->assertCount(6, $coltype->getAllCustomValues()); |
302
|
|
|
$this->assertEquals("?page=14&custom=9", $coltype->getUriAllCustoms()); |
303
|
|
|
$this->assertEquals("cops:custom:9", $coltype->getAllCustomsId()); |
304
|
|
|
$this->assertEquals("custom_09", $coltype->getTitle()); |
305
|
|
|
$this->assertEquals("Custom column example 09 (rating)", $coltype->getDatabaseDescription()); |
306
|
|
|
$this->assertEquals("Index of ratings", $coltype->getDescription()); |
307
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
308
|
|
|
|
309
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
310
|
|
|
$config['cops_calibre_custom_column'] = array(); |
311
|
|
|
Base::clearDb(); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
public function testColumnType10() |
315
|
|
|
{ |
316
|
|
|
global $config; |
317
|
|
|
|
318
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
319
|
|
|
$config['cops_calibre_custom_column'] = array("custom_10"); |
320
|
|
|
Base::clearDb(); |
321
|
|
|
|
322
|
|
|
$coltype = CustomColumnType::createByCustomID(11); |
323
|
|
|
|
324
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_10")); |
325
|
|
|
|
326
|
|
|
$this->assertEquals(11, $coltype->customId); |
327
|
|
|
$this->assertEquals("custom_10", $coltype->columnTitle); |
328
|
|
|
$this->assertEquals("bool", $coltype->datatype); |
329
|
|
|
$this->assertEquals("CustomColumnTypeBool", get_class($coltype)); |
330
|
|
|
|
331
|
|
|
$this->assertCount(3, $coltype->getAllCustomValues()); |
332
|
|
|
$this->assertEquals("?page=14&custom=11", $coltype->getUriAllCustoms()); |
333
|
|
|
$this->assertEquals("cops:custom:11", $coltype->getAllCustomsId()); |
334
|
|
|
$this->assertEquals("custom_10", $coltype->getTitle()); |
335
|
|
|
$this->assertEquals("Custom column example 10 (bool)", $coltype->getDatabaseDescription()); |
336
|
|
|
$this->assertEquals("Index of a boolean value", $coltype->getDescription()); |
337
|
|
|
$this->assertEquals(true, $coltype->isSearchable()); |
338
|
|
|
|
339
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
340
|
|
|
$config['cops_calibre_custom_column'] = array(); |
341
|
|
|
Base::clearDb(); |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
public function testColumnType11() |
345
|
|
|
{ |
346
|
|
|
global $config; |
347
|
|
|
|
348
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
349
|
|
|
$config['cops_calibre_custom_column'] = array("custom_11"); |
350
|
|
|
Base::clearDb(); |
351
|
|
|
|
352
|
|
|
$coltype = CustomColumnType::createByCustomID(15); |
353
|
|
|
|
354
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_11")); |
355
|
|
|
|
356
|
|
|
$this->assertEquals(NULL, $coltype); |
357
|
|
|
|
358
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
359
|
|
|
$config['cops_calibre_custom_column'] = array(); |
360
|
|
|
Base::clearDb(); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
public function testColumnType12() |
364
|
|
|
{ |
365
|
|
|
global $config; |
366
|
|
|
|
367
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
368
|
|
|
$config['cops_calibre_custom_column'] = array("custom_12"); |
369
|
|
|
Base::clearDb(); |
370
|
|
|
|
371
|
|
|
$coltype = CustomColumnType::createByCustomID(13); |
372
|
|
|
|
373
|
|
|
$this->assertEquals($coltype, CustomColumnType::createByLookup("custom_12")); |
374
|
|
|
|
375
|
|
|
$this->assertEquals(NULL, $coltype); |
376
|
|
|
|
377
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
378
|
|
|
$config['cops_calibre_custom_column'] = array(); |
379
|
|
|
Base::clearDb(); |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
public function testInvalidColumn1() |
383
|
|
|
{ |
384
|
|
|
global $config; |
385
|
|
|
|
386
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
387
|
|
|
$config['cops_calibre_custom_column'] = array("custom_12"); |
388
|
|
|
Base::clearDb(); |
389
|
|
|
|
390
|
|
|
$catch = false; |
391
|
|
|
try { |
392
|
|
|
CustomColumnType::createByCustomID(999); |
393
|
|
|
} catch (Exception $e) { |
394
|
|
|
$catch = true; |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
$this->assertTrue($catch); |
398
|
|
|
|
399
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
400
|
|
|
$config['cops_calibre_custom_column'] = array(); |
401
|
|
|
Base::clearDb(); |
402
|
|
|
} |
403
|
|
|
|
404
|
|
|
public function testInvalidColumn2() |
405
|
|
|
{ |
406
|
|
|
global $config; |
407
|
|
|
|
408
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
409
|
|
|
$config['cops_calibre_custom_column'] = array("custom_12"); |
410
|
|
|
Base::clearDb(); |
411
|
|
|
|
412
|
|
|
$coltype = CustomColumnType::createByLookup("__ERR__"); |
413
|
|
|
|
414
|
|
|
$this->assertEquals(NULL, $coltype); |
415
|
|
|
|
416
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
417
|
|
|
$config['cops_calibre_custom_column'] = array(); |
418
|
|
|
Base::clearDb(); |
419
|
|
|
} |
420
|
|
|
|
421
|
|
|
public function testIndexTypeAll() |
422
|
|
|
{ |
423
|
|
|
global $config; |
424
|
|
|
|
425
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
426
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10"); |
427
|
|
|
Base::clearDb(); |
428
|
|
|
|
429
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
430
|
|
|
$currentPage->InitializeContent(); |
431
|
|
|
|
432
|
|
|
$this->assertCount(15, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
433
|
|
|
$this->assertEquals("custom_01", $currentPage->entryArray[ 4]->title); |
434
|
|
|
$this->assertEquals("custom_02", $currentPage->entryArray[ 5]->title); |
435
|
|
|
$this->assertEquals("custom_04", $currentPage->entryArray[ 6]->title); |
436
|
|
|
$this->assertEquals("custom_05", $currentPage->entryArray[ 7]->title); |
437
|
|
|
$this->assertEquals("custom_06", $currentPage->entryArray[ 8]->title); |
438
|
|
|
$this->assertEquals("custom_07", $currentPage->entryArray[ 9]->title); |
439
|
|
|
$this->assertEquals("custom_08", $currentPage->entryArray[10]->title); |
440
|
|
|
$this->assertEquals("custom_09", $currentPage->entryArray[11]->title); |
441
|
|
|
$this->assertEquals("custom_10", $currentPage->entryArray[12]->title); |
442
|
|
|
|
443
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
444
|
|
|
$config['cops_calibre_custom_column'] = array(); |
445
|
|
|
Base::clearDb(); |
446
|
|
|
} |
447
|
|
|
|
448
|
|
|
public function testIndexType01() |
449
|
|
|
{ |
450
|
|
|
global $config; |
451
|
|
|
|
452
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
453
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01"); |
454
|
|
|
Base::clearDb(); |
455
|
|
|
|
456
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
457
|
|
|
$currentPage->InitializeContent(); |
458
|
|
|
|
459
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
460
|
|
|
$this->assertEquals("custom_01", $currentPage->entryArray[4]->title); |
461
|
|
|
$this->assertEquals("cops:custom:8", $currentPage->entryArray[4]->id); |
462
|
|
|
$this->assertEquals("Custom column example 01 (text)", $currentPage->entryArray[4]->content); |
463
|
|
|
$this->assertEquals(3, $currentPage->entryArray[4]->numberOfElement); |
464
|
|
|
$this->assertEquals("text", $currentPage->entryArray[4]->contentType); |
465
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(8)->getCount()); |
466
|
|
|
|
467
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
468
|
|
|
$config['cops_calibre_custom_column'] = array(); |
469
|
|
|
Base::clearDb(); |
470
|
|
|
} |
471
|
|
|
|
472
|
|
|
public function testIndexType02() |
473
|
|
|
{ |
474
|
|
|
global $config; |
475
|
|
|
|
476
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
477
|
|
|
$config['cops_calibre_custom_column'] = array("custom_02"); |
478
|
|
|
Base::clearDb(); |
479
|
|
|
|
480
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
481
|
|
|
$currentPage->InitializeContent(); |
482
|
|
|
|
483
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
484
|
|
|
$this->assertEquals("custom_02", $currentPage->entryArray[4]->title); |
485
|
|
|
$this->assertEquals("cops:custom:6", $currentPage->entryArray[4]->id); |
486
|
|
|
$this->assertEquals("Custom column example 02 (csv)", $currentPage->entryArray[4]->content); |
487
|
|
|
$this->assertEquals(3, $currentPage->entryArray[4]->numberOfElement); |
488
|
|
|
$this->assertEquals("text", $currentPage->entryArray[4]->contentType); |
489
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(6)->getCount()); |
490
|
|
|
|
491
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
492
|
|
|
$config['cops_calibre_custom_column'] = array(); |
493
|
|
|
Base::clearDb(); |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
public function testIndexType03() |
497
|
|
|
{ |
498
|
|
|
global $config; |
499
|
|
|
|
500
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
501
|
|
|
$config['cops_calibre_custom_column'] = array("custom_03"); |
502
|
|
|
Base::clearDb(); |
503
|
|
|
|
504
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
505
|
|
|
$currentPage->InitializeContent(); |
506
|
|
|
|
507
|
|
|
$this->assertCount(6, $currentPage->entryArray); // Authors, Series, Publishers, Languages, All, Recent |
508
|
|
|
|
509
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
510
|
|
|
$config['cops_calibre_custom_column'] = array(); |
511
|
|
|
Base::clearDb(); |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
public function testIndexType04() |
515
|
|
|
{ |
516
|
|
|
global $config; |
517
|
|
|
|
518
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
519
|
|
|
$config['cops_calibre_custom_column'] = array("custom_04"); |
520
|
|
|
Base::clearDb(); |
521
|
|
|
|
522
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
523
|
|
|
$currentPage->InitializeContent(); |
524
|
|
|
|
525
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
526
|
|
|
$this->assertEquals("custom_04", $currentPage->entryArray[4]->title); |
527
|
|
|
$this->assertEquals("cops:custom:4", $currentPage->entryArray[4]->id); |
528
|
|
|
$this->assertEquals("Alphabetical index of the 3 series", $currentPage->entryArray[4]->content); |
529
|
|
|
$this->assertEquals(3, $currentPage->entryArray[4]->numberOfElement); |
530
|
|
|
$this->assertEquals("series", $currentPage->entryArray[4]->contentType); |
531
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(4)->getCount()); |
532
|
|
|
|
533
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
534
|
|
|
$config['cops_calibre_custom_column'] = array(); |
535
|
|
|
Base::clearDb(); |
536
|
|
|
} |
537
|
|
|
|
538
|
|
|
public function testIndexType05() |
539
|
|
|
{ |
540
|
|
|
global $config; |
541
|
|
|
|
542
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
543
|
|
|
$config['cops_calibre_custom_column'] = array("custom_05"); |
544
|
|
|
Base::clearDb(); |
545
|
|
|
|
546
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
547
|
|
|
$currentPage->InitializeContent(); |
548
|
|
|
|
549
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
550
|
|
|
$this->assertEquals("custom_05", $currentPage->entryArray[4]->title); |
551
|
|
|
$this->assertEquals("cops:custom:5", $currentPage->entryArray[4]->id); |
552
|
|
|
$this->assertEquals("Alphabetical index of the 4 values", $currentPage->entryArray[4]->content); |
553
|
|
|
$this->assertEquals(4, $currentPage->entryArray[4]->numberOfElement); |
554
|
|
|
$this->assertEquals("enumeration", $currentPage->entryArray[4]->contentType); |
555
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(5)->getCount()); |
556
|
|
|
|
557
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
558
|
|
|
$config['cops_calibre_custom_column'] = array(); |
559
|
|
|
Base::clearDb(); |
560
|
|
|
} |
561
|
|
|
|
562
|
|
|
public function testIndexType06() |
563
|
|
|
{ |
564
|
|
|
global $config; |
565
|
|
|
|
566
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
567
|
|
|
$config['cops_calibre_custom_column'] = array("custom_06"); |
568
|
|
|
Base::clearDb(); |
569
|
|
|
|
570
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
571
|
|
|
$currentPage->InitializeContent(); |
572
|
|
|
|
573
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
574
|
|
|
$this->assertEquals("custom_06", $currentPage->entryArray[4]->title); |
575
|
|
|
$this->assertEquals("cops:custom:12", $currentPage->entryArray[4]->id); |
576
|
|
|
$this->assertEquals("Custom column example 06 (date)", $currentPage->entryArray[4]->content); |
577
|
|
|
$this->assertEquals(5, $currentPage->entryArray[4]->numberOfElement); |
578
|
|
|
$this->assertEquals("datetime", $currentPage->entryArray[4]->contentType); |
579
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(12)->getCount()); |
580
|
|
|
|
581
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
582
|
|
|
$config['cops_calibre_custom_column'] = array(); |
583
|
|
|
Base::clearDb(); |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
public function testIndexType07() |
587
|
|
|
{ |
588
|
|
|
global $config; |
589
|
|
|
|
590
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
591
|
|
|
$config['cops_calibre_custom_column'] = array("custom_07"); |
592
|
|
|
Base::clearDb(); |
593
|
|
|
|
594
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
595
|
|
|
$currentPage->InitializeContent(); |
596
|
|
|
|
597
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
598
|
|
|
$this->assertEquals("custom_07", $currentPage->entryArray[4]->title); |
599
|
|
|
$this->assertEquals("cops:custom:14", $currentPage->entryArray[4]->id); |
600
|
|
|
$this->assertEquals("Custom column example 07 (float)", $currentPage->entryArray[4]->content); |
601
|
|
|
$this->assertEquals(6, $currentPage->entryArray[4]->numberOfElement); |
602
|
|
|
$this->assertEquals("float", $currentPage->entryArray[4]->contentType); |
603
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(14)->getCount()); |
604
|
|
|
|
605
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
606
|
|
|
$config['cops_calibre_custom_column'] = array(); |
607
|
|
|
Base::clearDb(); |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
public function testIndexType08() |
611
|
|
|
{ |
612
|
|
|
global $config; |
613
|
|
|
|
614
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
615
|
|
|
$config['cops_calibre_custom_column'] = array("custom_08"); |
616
|
|
|
Base::clearDb(); |
617
|
|
|
|
618
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
619
|
|
|
$currentPage->InitializeContent(); |
620
|
|
|
|
621
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
622
|
|
|
$this->assertEquals("custom_08", $currentPage->entryArray[4]->title); |
623
|
|
|
$this->assertEquals("cops:custom:10", $currentPage->entryArray[4]->id); |
624
|
|
|
$this->assertEquals("Custom column example 08 (int)", $currentPage->entryArray[4]->content); |
625
|
|
|
$this->assertEquals(4, $currentPage->entryArray[4]->numberOfElement); |
626
|
|
|
$this->assertEquals("int", $currentPage->entryArray[4]->contentType); |
627
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(10)->getCount()); |
628
|
|
|
|
629
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
630
|
|
|
$config['cops_calibre_custom_column'] = array(); |
631
|
|
|
Base::clearDb(); |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
public function testIndexType09() |
635
|
|
|
{ |
636
|
|
|
global $config; |
637
|
|
|
|
638
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
639
|
|
|
$config['cops_calibre_custom_column'] = array("custom_09"); |
640
|
|
|
Base::clearDb(); |
641
|
|
|
|
642
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
643
|
|
|
$currentPage->InitializeContent(); |
644
|
|
|
|
645
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
646
|
|
|
$this->assertEquals("custom_09", $currentPage->entryArray[4]->title); |
647
|
|
|
$this->assertEquals("cops:custom:9", $currentPage->entryArray[4]->id); |
648
|
|
|
$this->assertEquals("Index of ratings", $currentPage->entryArray[4]->content); |
649
|
|
|
$this->assertEquals(6, $currentPage->entryArray[4]->numberOfElement); |
650
|
|
|
$this->assertEquals("rating", $currentPage->entryArray[4]->contentType); |
651
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(9)->getCount()); |
652
|
|
|
|
653
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
654
|
|
|
$config['cops_calibre_custom_column'] = array(); |
655
|
|
|
Base::clearDb(); |
656
|
|
|
} |
657
|
|
|
|
658
|
|
|
public function testIndexType10() |
659
|
|
|
{ |
660
|
|
|
global $config; |
661
|
|
|
|
662
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
663
|
|
|
$config['cops_calibre_custom_column'] = array("custom_10"); |
664
|
|
|
Base::clearDb(); |
665
|
|
|
|
666
|
|
|
$currentPage = Page::getPage(Base::PAGE_INDEX, NULL, NULL, "1"); |
667
|
|
|
$currentPage->InitializeContent(); |
668
|
|
|
|
669
|
|
|
$this->assertCount(7, $currentPage->entryArray); // Authors, Series, Publishers, Languages, custom, All, Recent |
670
|
|
|
$this->assertEquals("custom_10", $currentPage->entryArray[4]->title); |
671
|
|
|
$this->assertEquals("cops:custom:11", $currentPage->entryArray[4]->id); |
672
|
|
|
$this->assertEquals("Index of a boolean value", $currentPage->entryArray[4]->content); |
673
|
|
|
$this->assertEquals(3, $currentPage->entryArray[4]->numberOfElement); |
674
|
|
|
$this->assertEquals("bool", $currentPage->entryArray[4]->contentType); |
675
|
|
|
$this->assertEquals($currentPage->entryArray[4], CustomColumnType::createByCustomID(11)->getCount()); |
676
|
|
|
|
677
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
678
|
|
|
$config['cops_calibre_custom_column'] = array(); |
679
|
|
|
Base::clearDb(); |
680
|
|
|
} |
681
|
|
|
|
682
|
|
|
public function testAllCustomsType01() |
683
|
|
|
{ |
684
|
|
|
global $config; |
685
|
|
|
|
686
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
687
|
|
|
$_GET["custom"] = "8"; |
688
|
|
|
Base::clearDb(); |
689
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
690
|
|
|
$currentPage->InitializeContent(); |
691
|
|
|
|
692
|
|
|
|
693
|
|
|
$this->assertEquals("custom_01", $currentPage->title); |
694
|
|
|
$this->assertCount(3, $currentPage->entryArray); |
695
|
|
|
$this->assertEquals("cops:custom:8:3", $currentPage->entryArray[0]->id); |
696
|
|
|
$this->assertEquals("cops:custom:8:1", $currentPage->entryArray[1]->id); |
697
|
|
|
$this->assertEquals("cops:custom:8:2", $currentPage->entryArray[2]->id); |
698
|
|
|
|
699
|
|
|
|
700
|
|
|
$_GET["custom"] = NULL; |
701
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
702
|
|
|
Base::clearDb(); |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
public function testAllCustomsType02() |
706
|
|
|
{ |
707
|
|
|
global $config; |
708
|
|
|
|
709
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
710
|
|
|
$_GET["custom"] = "6"; |
711
|
|
|
Base::clearDb(); |
712
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
713
|
|
|
$currentPage->InitializeContent(); |
714
|
|
|
|
715
|
|
|
|
716
|
|
|
$this->assertEquals("custom_02", $currentPage->title); |
717
|
|
|
$this->assertCount(3, $currentPage->entryArray); |
718
|
|
|
$this->assertEquals("cops:custom:6:1", $currentPage->entryArray[0]->id); |
719
|
|
|
$this->assertEquals("cops:custom:6:2", $currentPage->entryArray[1]->id); |
720
|
|
|
$this->assertEquals("cops:custom:6:3", $currentPage->entryArray[2]->id); |
721
|
|
|
|
722
|
|
|
|
723
|
|
|
$_GET["custom"] = NULL; |
724
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
725
|
|
|
Base::clearDb(); |
726
|
|
|
} |
727
|
|
|
|
728
|
|
|
public function testAllCustomsType04() |
729
|
|
|
{ |
730
|
|
|
global $config; |
731
|
|
|
|
732
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
733
|
|
|
$_GET["custom"] = "4"; |
734
|
|
|
Base::clearDb(); |
735
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
736
|
|
|
$currentPage->InitializeContent(); |
737
|
|
|
|
738
|
|
|
|
739
|
|
|
$this->assertEquals("custom_04", $currentPage->title); |
740
|
|
|
$this->assertCount(3, $currentPage->entryArray); |
741
|
|
|
$this->assertEquals("cops:custom:4:4", $currentPage->entryArray[0]->id); |
742
|
|
|
$this->assertEquals("cops:custom:4:5", $currentPage->entryArray[1]->id); |
743
|
|
|
$this->assertEquals("cops:custom:4:6", $currentPage->entryArray[2]->id); |
744
|
|
|
|
745
|
|
|
|
746
|
|
|
$_GET["custom"] = NULL; |
747
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
748
|
|
|
Base::clearDb(); |
749
|
|
|
} |
750
|
|
|
|
751
|
|
|
public function testAllCustomsType05() |
752
|
|
|
{ |
753
|
|
|
global $config; |
754
|
|
|
|
755
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
756
|
|
|
$_GET["custom"] = "5"; |
757
|
|
|
Base::clearDb(); |
758
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
759
|
|
|
$currentPage->InitializeContent(); |
760
|
|
|
|
761
|
|
|
|
762
|
|
|
$this->assertEquals("custom_05", $currentPage->title); |
763
|
|
|
$this->assertCount(4, $currentPage->entryArray); |
764
|
|
|
$this->assertEquals("cops:custom:5:3", $currentPage->entryArray[0]->id); |
765
|
|
|
$this->assertEquals("cops:custom:5:4", $currentPage->entryArray[1]->id); |
766
|
|
|
$this->assertEquals("cops:custom:5:5", $currentPage->entryArray[2]->id); |
767
|
|
|
$this->assertEquals("cops:custom:5:6", $currentPage->entryArray[3]->id); |
768
|
|
|
|
769
|
|
|
|
770
|
|
|
$_GET["custom"] = NULL; |
771
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
772
|
|
|
Base::clearDb(); |
773
|
|
|
} |
774
|
|
|
|
775
|
|
|
public function testAllCustomsType06() |
776
|
|
|
{ |
777
|
|
|
global $config; |
778
|
|
|
|
779
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
780
|
|
|
$_GET["custom"] = "12"; |
781
|
|
|
Base::clearDb(); |
782
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
783
|
|
|
$currentPage->InitializeContent(); |
784
|
|
|
|
785
|
|
|
|
786
|
|
|
$this->assertEquals("custom_06", $currentPage->title); |
787
|
|
|
$this->assertCount(5, $currentPage->entryArray); |
788
|
|
|
$this->assertEquals("cops:custom:12:2000-01-01", $currentPage->entryArray[0]->id); |
789
|
|
|
$this->assertEquals("cops:custom:12:2000-01-02", $currentPage->entryArray[1]->id); |
790
|
|
|
$this->assertEquals("cops:custom:12:2000-01-03", $currentPage->entryArray[2]->id); |
791
|
|
|
$this->assertEquals("cops:custom:12:2016-04-20", $currentPage->entryArray[3]->id); |
792
|
|
|
$this->assertEquals("cops:custom:12:2016-04-24", $currentPage->entryArray[4]->id); |
793
|
|
|
|
794
|
|
|
|
795
|
|
|
$_GET["custom"] = NULL; |
796
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
797
|
|
|
Base::clearDb(); |
798
|
|
|
} |
799
|
|
|
|
800
|
|
|
public function testAllCustomsType07() |
801
|
|
|
{ |
802
|
|
|
global $config; |
803
|
|
|
|
804
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
805
|
|
|
$_GET["custom"] = "14"; |
806
|
|
|
Base::clearDb(); |
807
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
808
|
|
|
$currentPage->InitializeContent(); |
809
|
|
|
|
810
|
|
|
|
811
|
|
|
$this->assertEquals("custom_07", $currentPage->title); |
812
|
|
|
$this->assertCount(6, $currentPage->entryArray); |
813
|
|
|
$this->assertEquals("cops:custom:14:-99.0", $currentPage->entryArray[0]->id); |
814
|
|
|
$this->assertEquals("cops:custom:14:0.0", $currentPage->entryArray[1]->id); |
815
|
|
|
$this->assertEquals("cops:custom:14:0.1", $currentPage->entryArray[2]->id); |
816
|
|
|
$this->assertEquals("cops:custom:14:0.2", $currentPage->entryArray[3]->id); |
817
|
|
|
$this->assertEquals("cops:custom:14:11.0", $currentPage->entryArray[4]->id); |
818
|
|
|
$this->assertEquals("cops:custom:14:100000.0", $currentPage->entryArray[5]->id); |
819
|
|
|
|
820
|
|
|
|
821
|
|
|
$_GET["custom"] = NULL; |
822
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
823
|
|
|
Base::clearDb(); |
824
|
|
|
} |
825
|
|
|
|
826
|
|
|
public function testAllCustomsType08() |
827
|
|
|
{ |
828
|
|
|
global $config; |
829
|
|
|
|
830
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
831
|
|
|
$_GET["custom"] = "10"; |
832
|
|
|
Base::clearDb(); |
833
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
834
|
|
|
$currentPage->InitializeContent(); |
835
|
|
|
|
836
|
|
|
|
837
|
|
|
$this->assertEquals("custom_08", $currentPage->title); |
838
|
|
|
$this->assertCount(4, $currentPage->entryArray); |
839
|
|
|
$this->assertEquals("cops:custom:10:-2", $currentPage->entryArray[0]->id); |
840
|
|
|
$this->assertEquals("cops:custom:10:-1", $currentPage->entryArray[1]->id); |
841
|
|
|
$this->assertEquals("cops:custom:10:1", $currentPage->entryArray[2]->id); |
842
|
|
|
$this->assertEquals("cops:custom:10:2", $currentPage->entryArray[3]->id); |
843
|
|
|
|
844
|
|
|
|
845
|
|
|
$_GET["custom"] = NULL; |
846
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
847
|
|
|
Base::clearDb(); |
848
|
|
|
} |
849
|
|
|
|
850
|
|
|
public function testAllCustomsType09() |
851
|
|
|
{ |
852
|
|
|
global $config; |
853
|
|
|
|
854
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
855
|
|
|
$_GET["custom"] = "9"; |
856
|
|
|
Base::clearDb(); |
857
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
858
|
|
|
$currentPage->InitializeContent(); |
859
|
|
|
|
860
|
|
|
|
861
|
|
|
$this->assertEquals("custom_09", $currentPage->title); |
862
|
|
|
$this->assertCount(6, $currentPage->entryArray); |
863
|
|
|
$this->assertEquals("cops:custom:9:0", $currentPage->entryArray[0]->id); |
864
|
|
|
$this->assertEquals("cops:custom:9:2", $currentPage->entryArray[1]->id); |
865
|
|
|
$this->assertEquals("cops:custom:9:4", $currentPage->entryArray[2]->id); |
866
|
|
|
$this->assertEquals("cops:custom:9:6", $currentPage->entryArray[3]->id); |
867
|
|
|
$this->assertEquals("cops:custom:9:8", $currentPage->entryArray[4]->id); |
868
|
|
|
$this->assertEquals("cops:custom:9:10", $currentPage->entryArray[5]->id); |
869
|
|
|
|
870
|
|
|
|
871
|
|
|
$_GET["custom"] = NULL; |
872
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
873
|
|
|
Base::clearDb(); |
874
|
|
|
} |
875
|
|
|
|
876
|
|
|
public function testAllCustomsType10() |
877
|
|
|
{ |
878
|
|
|
global $config; |
879
|
|
|
|
880
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
881
|
|
|
$_GET["custom"] = "11"; |
882
|
|
|
Base::clearDb(); |
883
|
|
|
$currentPage = Page::getPage(Base::PAGE_ALL_CUSTOMS, NULL, NULL, "1"); |
884
|
|
|
$currentPage->InitializeContent(); |
885
|
|
|
|
886
|
|
|
|
887
|
|
|
$this->assertEquals("custom_10", $currentPage->title); |
888
|
|
|
$this->assertCount(3, $currentPage->entryArray); |
889
|
|
|
$this->assertEquals("cops:custom:11:-1", $currentPage->entryArray[0]->id); |
890
|
|
|
$this->assertEquals("cops:custom:11:0", $currentPage->entryArray[1]->id); |
891
|
|
|
$this->assertEquals("cops:custom:11:1", $currentPage->entryArray[2]->id); |
892
|
|
|
|
893
|
|
|
|
894
|
|
|
$_GET["custom"] = NULL; |
895
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
896
|
|
|
Base::clearDb(); |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
public function testDetailTypeAllEntryIDs() |
900
|
|
|
{ |
901
|
|
|
global $config; |
902
|
|
|
|
903
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
904
|
|
|
$_GET["custom"] = "11"; |
905
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); |
906
|
|
|
Base::clearDb(); |
907
|
|
|
|
908
|
|
|
$currentPage = Page::getPage(Base::PAGE_CUSTOM_DETAIL, "0", NULL, "1"); |
909
|
|
|
$currentPage->InitializeContent(); |
910
|
|
|
|
911
|
|
|
/* @var EntryBook[] $entries */ |
912
|
|
|
$entries = $currentPage->entryArray; |
913
|
|
|
|
914
|
|
|
$this->assertCount(6, $entries); |
915
|
|
|
|
916
|
|
|
$customcolumnValues = $entries[0]->book->getCustomColumnValues($config['cops_calibre_custom_column']); |
917
|
|
|
|
918
|
|
|
$this->assertCount(10, $customcolumnValues); |
919
|
|
|
|
920
|
|
|
$this->assertEquals("cops:custom:8:1", $customcolumnValues[0]->getEntryId()); |
921
|
|
|
$this->assertEquals("cops:custom:6:3", $customcolumnValues[1]->getEntryId()); |
922
|
|
|
$this->assertEquals("cops:custom:7:3", $customcolumnValues[2]->getEntryId()); |
923
|
|
|
$this->assertEquals("cops:custom:4:4", $customcolumnValues[3]->getEntryId()); |
924
|
|
|
$this->assertEquals("cops:custom:5:6", $customcolumnValues[4]->getEntryId()); |
925
|
|
|
$this->assertEquals("cops:custom:12:2016-04-24", $customcolumnValues[5]->getEntryId()); |
926
|
|
|
$this->assertEquals("cops:custom:14:11.0", $customcolumnValues[6]->getEntryId()); |
927
|
|
|
$this->assertEquals("cops:custom:10:-2", $customcolumnValues[7]->getEntryId()); |
928
|
|
|
$this->assertEquals("cops:custom:9:2", $customcolumnValues[8]->getEntryId()); |
929
|
|
|
$this->assertEquals("cops:custom:11:0", $customcolumnValues[9]->getEntryId()); |
930
|
|
|
|
931
|
|
|
$_GET["custom"] = NULL; |
932
|
|
|
$config['cops_calibre_custom_column'] = array(); |
933
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
934
|
|
|
Base::clearDb(); |
935
|
|
|
} |
936
|
|
|
|
937
|
|
|
public function testRenderCustomColumns() |
938
|
|
|
{ |
939
|
|
|
global $config; |
940
|
|
|
|
941
|
|
|
$_SERVER["HTTP_USER_AGENT"] = "Firefox"; |
942
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
943
|
|
|
$_GET["custom"] = "11"; |
944
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); |
945
|
|
|
$config['cops_calibre_custom_column_list'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); |
946
|
|
|
$config['cops_calibre_custom_column_preview'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); |
947
|
|
|
Base::clearDb(); |
948
|
|
|
|
949
|
|
|
|
950
|
|
|
$book = Book::getBookById(223); |
951
|
|
|
$json = JSONRenderer::getBookContentArray($book); |
|
|
|
|
952
|
|
|
|
953
|
|
|
/* @var CustomColumn[] $custom */ |
954
|
|
|
$custom = $json["customcolumns_list"]; |
955
|
|
|
|
956
|
|
|
$this->assertEquals("custom_01", $custom[0]['customColumnType']['columnTitle']); |
957
|
|
|
$this->assertEquals("text_2", $custom[0]['htmlvalue']); |
958
|
|
|
|
959
|
|
|
$this->assertEquals("custom_02", $custom[1]['customColumnType']['columnTitle']); |
960
|
|
|
$this->assertEquals("a", $custom[1]['htmlvalue']); |
961
|
|
|
|
962
|
|
|
$this->assertEquals("custom_03", $custom[2]['customColumnType']['columnTitle']); |
963
|
|
|
$this->assertEquals("<div>Not Set</div>", $custom[2]['htmlvalue']); |
964
|
|
|
|
965
|
|
|
$this->assertEquals("custom_04", $custom[3]['customColumnType']['columnTitle']); |
966
|
|
|
$this->assertEquals("", $custom[3]['htmlvalue']); |
967
|
|
|
|
968
|
|
|
$this->assertEquals("custom_05", $custom[4]['customColumnType']['columnTitle']); |
969
|
|
|
$this->assertEquals("val05", $custom[4]['htmlvalue']); |
970
|
|
|
|
971
|
|
|
$this->assertEquals("custom_06", $custom[5]['customColumnType']['columnTitle']); |
972
|
|
|
$this->assertEquals("Not Set", $custom[5]['htmlvalue']); |
973
|
|
|
|
974
|
|
|
$this->assertEquals("custom_07", $custom[6]['customColumnType']['columnTitle']); |
975
|
|
|
$this->assertEquals("100000.0", $custom[6]['htmlvalue']); |
976
|
|
|
|
977
|
|
|
$this->assertEquals("custom_08", $custom[7]['customColumnType']['columnTitle']); |
978
|
|
|
$this->assertEquals("Not Set", $custom[7]['htmlvalue']); |
979
|
|
|
|
980
|
|
|
$this->assertEquals("custom_09", $custom[8]['customColumnType']['columnTitle']); |
981
|
|
|
$this->assertEquals("Not Set", $custom[8]['htmlvalue']); |
982
|
|
|
|
983
|
|
|
$this->assertEquals("custom_10", $custom[9]['customColumnType']['columnTitle']); |
984
|
|
|
$this->assertEquals("No", $custom[9]['htmlvalue']); |
985
|
|
|
|
986
|
|
|
$_SERVER["HTTP_USER_AGENT"] = ""; |
987
|
|
|
$_GET["custom"] = NULL; |
988
|
|
|
$config['cops_calibre_custom_column'] = array(); |
989
|
|
|
$config['cops_calibre_custom_column_list'] = array(); |
990
|
|
|
$config['cops_calibre_custom_column_preview'] = array(); |
991
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
992
|
|
|
Base::clearDb(); |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
public function testQueries() |
996
|
|
|
{ |
997
|
|
|
global $config; |
998
|
|
|
|
999
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
1000
|
|
|
$_GET["custom"] = "11"; |
1001
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); |
1002
|
|
|
Base::clearDb(); |
1003
|
|
|
|
1004
|
|
|
|
1005
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_01")->getCustom("1")->getQuery(); |
1006
|
|
|
Book::getEntryArray($query, $params, 1); |
1007
|
|
|
|
1008
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_02")->getCustom("3")->getQuery(); |
1009
|
|
|
Book::getEntryArray($query, $params, 1); |
1010
|
|
|
|
1011
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_03")->getCustom("3")->getQuery(); |
1012
|
|
|
Book::getEntryArray($query, $params, 1); |
1013
|
|
|
|
1014
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_04")->getCustom("4")->getQuery(); |
1015
|
|
|
Book::getEntryArray($query, $params, 1); |
1016
|
|
|
|
1017
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_05")->getCustom("6")->getQuery(); |
1018
|
|
|
Book::getEntryArray($query, $params, 1); |
1019
|
|
|
|
1020
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_06")->getCustom("2016-04-24")->getQuery(); |
1021
|
|
|
Book::getEntryArray($query, $params, 1); |
1022
|
|
|
|
1023
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_07")->getCustom("11.0")->getQuery(); |
1024
|
|
|
Book::getEntryArray($query, $params, 1); |
1025
|
|
|
|
1026
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_08")->getCustom("-2")->getQuery(); |
1027
|
|
|
Book::getEntryArray($query, $params, 1); |
1028
|
|
|
|
1029
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_09")->getCustom("0")->getQuery(); |
1030
|
|
|
Book::getEntryArray($query, $params, 1); |
1031
|
|
|
|
1032
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_09")->getCustom("1")->getQuery(); |
1033
|
|
|
Book::getEntryArray($query, $params, 1); |
1034
|
|
|
|
1035
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_10")->getCustom("-1")->getQuery(); |
1036
|
|
|
Book::getEntryArray($query, $params, 1); |
1037
|
|
|
|
1038
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_10")->getCustom("0")->getQuery(); |
1039
|
|
|
Book::getEntryArray($query, $params, 1); |
1040
|
|
|
|
1041
|
|
|
list($query, $params) = CustomColumnType::createByLookup("custom_10")->getCustom("1")->getQuery(); |
1042
|
|
|
Book::getEntryArray($query, $params, 1); |
1043
|
|
|
|
1044
|
|
|
$_GET["custom"] = NULL; |
1045
|
|
|
$config['cops_calibre_custom_column'] = array(); |
1046
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
1047
|
|
|
Base::clearDb(); |
1048
|
|
|
} |
1049
|
|
|
|
1050
|
|
|
public function testGetURI() |
1051
|
|
|
{ |
1052
|
|
|
global $config; |
1053
|
|
|
|
1054
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithCustomColumns/"; |
1055
|
|
|
$_GET["custom"] = "11"; |
1056
|
|
|
$config['cops_calibre_custom_column'] = array("custom_01", "custom_02", "custom_03", "custom_04", "custom_05", "custom_06", "custom_07", "custom_08", "custom_09", "custom_10", "custom_11"); |
1057
|
|
|
Base::clearDb(); |
1058
|
|
|
|
1059
|
|
|
|
1060
|
|
|
$custom = CustomColumnType::createByLookup("custom_01")->getCustom("1"); |
1061
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("1"), $custom->getQuery()); |
1062
|
|
|
|
1063
|
|
|
$custom = CustomColumnType::createByLookup("custom_02")->getCustom("3"); |
1064
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("3"), $custom->getQuery()); |
1065
|
|
|
|
1066
|
|
|
$custom = CustomColumnType::createByLookup("custom_03")->getCustom("3"); |
1067
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("3"), $custom->getQuery()); |
1068
|
|
|
|
1069
|
|
|
$custom = CustomColumnType::createByLookup("custom_04")->getCustom("4"); |
1070
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("4"), $custom->getQuery()); |
1071
|
|
|
|
1072
|
|
|
$custom = CustomColumnType::createByLookup("custom_05")->getCustom("6"); |
1073
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("6"), $custom->getQuery()); |
1074
|
|
|
|
1075
|
|
|
$custom = CustomColumnType::createByLookup("custom_06")->getCustom("2016-04-24"); |
1076
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("2016-04-24"), $custom->getQuery()); |
1077
|
|
|
|
1078
|
|
|
$custom = CustomColumnType::createByLookup("custom_07")->getCustom("11.0"); |
1079
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("11.0"), $custom->getQuery()); |
1080
|
|
|
|
1081
|
|
|
$custom = CustomColumnType::createByLookup("custom_08")->getCustom("-2"); |
1082
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("-2"), $custom->getQuery()); |
1083
|
|
|
|
1084
|
|
|
$custom = CustomColumnType::createByLookup("custom_09")->getCustom("0"); |
1085
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("0"), $custom->getQuery()); |
1086
|
|
|
|
1087
|
|
|
$custom = CustomColumnType::createByLookup("custom_09")->getCustom("1"); |
1088
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("1"), $custom->getQuery()); |
1089
|
|
|
|
1090
|
|
|
$custom = CustomColumnType::createByLookup("custom_10")->getCustom("-1"); |
1091
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("-1"), $custom->getQuery()); |
1092
|
|
|
|
1093
|
|
|
$custom = CustomColumnType::createByLookup("custom_10")->getCustom("0"); |
1094
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("0"), $custom->getQuery()); |
1095
|
|
|
|
1096
|
|
|
$custom = CustomColumnType::createByLookup("custom_10")->getCustom("1"); |
1097
|
|
|
$this->assertEquals($custom->customColumnType->getQuery("1"), $custom->getQuery()); |
1098
|
|
|
|
1099
|
|
|
$_GET["custom"] = NULL; |
1100
|
|
|
$config['cops_calibre_custom_column'] = array(); |
1101
|
|
|
$config['calibre_directory'] = dirname(__FILE__) . "/BaseWithSomeBooks/"; |
1102
|
|
|
Base::clearDb(); |
1103
|
|
|
} |
1104
|
|
|
} |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: