View | Details | Raw Unified | Return to bug 18936
Collapse All | Expand All

(-)a/t/db_dependent/Koha/IssuingRules.t (-85 / +170 lines)
Lines 49-54 subtest 'get_effective_issuing_rule' => sub { Link Here
49
        Koha::CirculationRules->delete;
49
        Koha::CirculationRules->delete;
50
50
51
        is(Koha::CirculationRules->search->count, 0, 'There are no issuing rules.');
51
        is(Koha::CirculationRules->search->count, 0, 'There are no issuing rules.');
52
        # undef, undef, undef => 1
52
        $rule = Koha::CirculationRules->get_effective_rule({
53
        $rule = Koha::CirculationRules->get_effective_rule({
53
            branchcode   => undef,
54
            branchcode   => undef,
54
            categorycode => undef,
55
            categorycode => undef,
Lines 58-84 subtest 'get_effective_issuing_rule' => sub { Link Here
58
        });
59
        });
59
        is($rule, undef, 'When I attempt to get effective issuing rule by'
60
        is($rule, undef, 'When I attempt to get effective issuing rule by'
60
           .' providing undefined values, then undef is returned.');
61
           .' providing undefined values, then undef is returned.');
61
        ok(Koha::CirculationRule->new({
62
62
            branchcode => undef,
63
       # undef, undef, undef => 2
63
            categorycode => undef,
64
        ok(
64
            itemtype => undef,
65
            Koha::CirculationRule->new(
65
            rule_name => 'fine',
66
                {
66
            rule_value => 2,
67
                    branchcode   => undef,
67
        })->store, 'Given I added an issuing rule branchcode => undef,'
68
                    categorycode => undef,
69
                    itemtype     => undef,
70
                    rule_name    => 'fine',
71
                    rule_value   => 2,
72
                }
73
              )->store,
74
            'Given I added an issuing rule branchcode => undef,'
68
           .' categorycode => undef, itemtype => undef,');
75
           .' categorycode => undef, itemtype => undef,');
69
        $rule = Koha::CirculationRules->get_effective_rule({
76
        $rule = Koha::CirculationRules->get_effective_rule({
70
            branchcode   => undef,
77
            branchcode   => undef,
71
            categorycode => undef,
78
            categorycode => undef,
72
            itemtype     => undef,
79
            itemtype     => undef,
73
            rule_name    => 'fine',
80
            rule_name    => 'fine',
74
            rule_value => 3,
75
        });
81
        });
76
        _is_row_match(
82
        _is_row_match(
77
            $rule,
83
            $rule,
78
            {
84
            {
79
                branchcode => undef,
85
                branchcode   => undef,
80
                categorycode => undef,
86
                categorycode => undef,
81
                itemtype => undef
87
                itemtype     => undef,
88
                rule_name    => 'fine',
89
                rule_value   => 2,
82
            },
90
            },
83
            'When I attempt to get effective'
91
            'When I attempt to get effective'
84
           .' issuing rule by providing undefined values, then the above one is'
92
           .' issuing rule by providing undefined values, then the above one is'
Lines 97-107 subtest 'get_effective_issuing_rule' => sub { Link Here
97
            categorycode => $categorycode,
105
            categorycode => $categorycode,
98
            itemtype     => $itemtype,
106
            itemtype     => $itemtype,
99
            rule_name    => 'fine',
107
            rule_name    => 'fine',
100
            rule_value   => 4,
101
        });
108
        });
102
        is($rule, undef, 'When I attempt to get effective issuing rule, then undef'
109
        is($rule, undef, 'When I attempt to get effective issuing rule, then undef'
103
                        .' is returned.');
110
                        .' is returned.');
104
111
112
        # undef, undef, undef => 5
105
        ok(Koha::CirculationRule->new({
113
        ok(Koha::CirculationRule->new({
106
            branchcode => undef,
114
            branchcode => undef,
107
            categorycode => undef,
115
            categorycode => undef,
Lines 114-302 subtest 'get_effective_issuing_rule' => sub { Link Here
114
            categorycode => $categorycode,
122
            categorycode => $categorycode,
115
            itemtype     => $itemtype,
123
            itemtype     => $itemtype,
116
            rule_name    => 'fine',
124
            rule_name    => 'fine',
117
            rule_value   => 6,
118
        });
125
        });
119
        _is_row_match(
126
        _is_row_match(
120
            $rule,
127
            $rule,
121
            {
128
            {
122
                branchcode => undef,
129
                branchcode   => undef,
123
                categorycode => undef,
130
                categorycode => undef,
124
                itemtype => undef
131
                itemtype     => undef,
132
                rule_name    => 'fine',
133
                rule_value   => 5,
125
            },
134
            },
126
            'When I attempt to get effective issuing rule,'
135
            'When I attempt to get effective issuing rule,'
127
           .' then the above one is returned.'
136
           .' then the above one is returned.'
128
        );
137
        );
129
138
130
        ok(Koha::CirculationRule->new({
139
        # undef, undef, undef     => 5
131
            branchcode => undef,
140
        # undef, undef, $itemtype => 7
132
            categorycode => undef,
141
        ok(
133
            itemtype => $itemtype,
142
            Koha::CirculationRule->new(
134
            rule_name => 'fine',
143
                {
135
            rule_value   => 7,
144
                    branchcode   => undef,
136
        })->store, "Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => $itemtype,");
145
                    categorycode => undef,
146
                    itemtype     => $itemtype,
147
                    rule_name    => 'fine',
148
                    rule_value   => 7,
149
                }
150
              )->store,
151
            "Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => $itemtype,"
152
        );
137
        $rule = Koha::CirculationRules->get_effective_rule({
153
        $rule = Koha::CirculationRules->get_effective_rule({
138
            branchcode   => $branchcode,
154
            branchcode   => $branchcode,
139
            categorycode => $categorycode,
155
            categorycode => $categorycode,
140
            itemtype     => $itemtype,
156
            itemtype     => $itemtype,
141
            rule_name    => 'fine',
157
            rule_name    => 'fine',
142
            rule_value   => 8,
143
        });
158
        });
144
        _is_row_match(
159
        _is_row_match(
145
            $rule,
160
            $rule,
146
            {
161
            {
147
                branchcode => undef,
162
                branchcode   => undef,
148
                categorycode => undef,
163
                categorycode => undef,
149
                itemtype => $itemtype
164
                itemtype     => $itemtype,
165
                rule_name    => 'fine',
166
                rule_value   => 7,
150
            },
167
            },
151
            'When I attempt to get effective issuing rule,'
168
            'When I attempt to get effective issuing rule,'
152
           .' then the above one is returned.'
169
           .' then the above one is returned.'
153
        );
170
        );
154
171
155
        ok(Koha::CirculationRule->new({
172
        # undef, undef,         undef     => 5
156
            branchcode => undef,
173
        # undef, undef,         $itemtype => 7
157
            categorycode => $categorycode,
174
        # undef, $categorycode, undef     => 9
158
            itemtype => undef,
175
        ok(
159
            rule_name => 'fine',
176
            Koha::CirculationRule->new(
160
            rule_value   => 9,
177
                {
161
        })->store, "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => undef,");
178
                    branchcode   => undef,
179
                    categorycode => $categorycode,
180
                    itemtype     => undef,
181
                    rule_name    => 'fine',
182
                    rule_value   => 9,
183
                }
184
              )->store,
185
            "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => undef,"
186
        );
162
        $rule = Koha::CirculationRules->get_effective_rule({
187
        $rule = Koha::CirculationRules->get_effective_rule({
163
            branchcode   => $branchcode,
188
            branchcode   => $branchcode,
164
            categorycode => $categorycode,
189
            categorycode => $categorycode,
165
            itemtype     => $itemtype,
190
            itemtype     => $itemtype,
166
            rule_name    => 'fine',
191
            rule_name    => 'fine',
167
            rule_value   => 10,
168
        });
192
        });
169
        _is_row_match(
193
        _is_row_match(
170
            $rule,
194
            $rule,
171
            {
195
            {
172
                branchcode => undef,
196
                branchcode   => undef,
173
                categorycode => $categorycode,
197
                categorycode => $categorycode,
174
                itemtype => undef
198
                itemtype     => undef,
199
                rule_name    => 'fine',
200
                rule_value   => 9,
175
            },
201
            },
176
            'When I attempt to get effective issuing rule,'
202
            'When I attempt to get effective issuing rule,'
177
           .' then the above one is returned.'
203
           .' then the above one is returned.'
178
        );
204
        );
179
205
180
        ok(Koha::CirculationRule->new({
206
        # undef, undef,         undef     => 5
181
            branchcode => undef,
207
        # undef, undef,         $itemtype => 7
182
            categorycode => $categorycode,
208
        # undef, $categorycode, undef     => 9
183
            itemtype => $itemtype,
209
        # undef, $categorycode, $itemtype => 11
184
            rule_name => 'fine',
210
        ok(
185
            rule_value   => 11,
211
            Koha::CirculationRule->new(
186
        })->store, "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => $itemtype,");
212
                {
213
                    branchcode   => undef,
214
                    categorycode => $categorycode,
215
                    itemtype     => $itemtype,
216
                    rule_name    => 'fine',
217
                    rule_value   => 11,
218
                }
219
              )->store,
220
            "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => $itemtype,"
221
        );
187
        $rule = Koha::CirculationRules->get_effective_rule({
222
        $rule = Koha::CirculationRules->get_effective_rule({
188
            branchcode   => $branchcode,
223
            branchcode   => $branchcode,
189
            categorycode => $categorycode,
224
            categorycode => $categorycode,
190
            itemtype     => $itemtype,
225
            itemtype     => $itemtype,
191
            rule_name    => 'fine',
226
            rule_name    => 'fine',
192
            rule_value   => 12,
193
        });
227
        });
194
        _is_row_match(
228
        _is_row_match(
195
            $rule,
229
            $rule,
196
            {
230
            {
197
                branchcode => undef,
231
                branchcode   => undef,
198
                categorycode => $categorycode,
232
                categorycode => $categorycode,
199
                itemtype => $itemtype
233
                itemtype     => $itemtype,
234
                rule_name    => 'fine',
235
                rule_value   => 11,
200
            },
236
            },
201
            'When I attempt to get effective issuing rule,'
237
            'When I attempt to get effective issuing rule,'
202
           .' then the above one is returned.'
238
           .' then the above one is returned.'
203
        );
239
        );
204
240
205
        ok(Koha::CirculationRule->new({
241
        # undef,       undef,         undef     => 5
206
            branchcode => $branchcode,
242
        # undef,       undef,         $itemtype => 7
207
            categorycode => undef,
243
        # undef,       $categorycode, undef     => 9
208
            itemtype => undef,
244
        # undef,       $categorycode, $itemtype => 11
209
            rule_name => 'fine',
245
        # $branchcode, undef,         undef     => 13
210
            rule_value   => 13,
246
        ok(
211
        })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => undef,");
247
            Koha::CirculationRule->new(
248
                {
249
                    branchcode   => $branchcode,
250
                    categorycode => undef,
251
                    itemtype     => undef,
252
                    rule_name    => 'fine',
253
                    rule_value   => 13,
254
                }
255
              )->store,
256
            "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => undef,"
257
        );
212
        $rule = Koha::CirculationRules->get_effective_rule({
258
        $rule = Koha::CirculationRules->get_effective_rule({
213
            branchcode   => $branchcode,
259
            branchcode   => $branchcode,
214
            categorycode => $categorycode,
260
            categorycode => $categorycode,
215
            itemtype     => $itemtype,
261
            itemtype     => $itemtype,
216
            rule_name    => 'fine',
262
            rule_name    => 'fine',
217
            rule_value   => 14,
218
        });
263
        });
219
        _is_row_match(
264
        _is_row_match(
220
            $rule,
265
            $rule,
221
            {
266
            {
222
                branchcode => $branchcode,
267
                branchcode   => $branchcode,
223
                categorycode => undef,
268
                categorycode => undef,
224
                itemtype => undef
269
                itemtype     => undef,
270
                rule_name    => 'fine',
271
                rule_value   => 13,
225
            },
272
            },
226
            'When I attempt to get effective issuing rule,'
273
            'When I attempt to get effective issuing rule,'
227
           .' then the above one is returned.'
274
           .' then the above one is returned.'
228
        );
275
        );
229
276
230
        ok(Koha::CirculationRule->new({
277
        # undef,       undef,         undef     => 5
231
            branchcode => $branchcode,
278
        # undef,       undef,         $itemtype => 7
232
            categorycode => undef,
279
        # undef,       $categorycode, undef     => 9
233
            itemtype => $itemtype,
280
        # undef,       $categorycode, $itemtype => 11
234
            rule_name => 'fine',
281
        # $branchcode, undef,         undef     => 13
235
            rule_value   => 15,
282
        # $branchcode, undef,         $itemtype => 15
236
        })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => $itemtype,");
283
        ok(
284
            Koha::CirculationRule->new(
285
                {
286
                    branchcode   => $branchcode,
287
                    categorycode => undef,
288
                    itemtype     => $itemtype,
289
                    rule_name    => 'fine',
290
                    rule_value   => 15,
291
                }
292
              )->store,
293
            "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => $itemtype,"
294
        );
237
        $rule = Koha::CirculationRules->get_effective_rule({
295
        $rule = Koha::CirculationRules->get_effective_rule({
238
            branchcode   => $branchcode,
296
            branchcode   => $branchcode,
239
            categorycode => $categorycode,
297
            categorycode => $categorycode,
240
            itemtype     => $itemtype,
298
            itemtype     => $itemtype,
241
            rule_name    => 'fine',
299
            rule_name    => 'fine',
242
            rule_value   => 16,
243
        });
300
        });
244
        _is_row_match(
301
        _is_row_match(
245
            $rule,
302
            $rule,
246
            {
303
            {
247
                branchcode => $branchcode,
304
                branchcode   => $branchcode,
248
                categorycode => undef,
305
                categorycode => undef,
249
                itemtype => $itemtype
306
                itemtype     => $itemtype,
307
                rule_name    => 'fine',
308
                rule_value   => 15,
250
            },
309
            },
251
            'When I attempt to get effective issuing rule,'
310
            'When I attempt to get effective issuing rule,'
252
           .' then the above one is returned.'
311
           .' then the above one is returned.'
253
        );
312
        );
254
313
255
        ok(Koha::CirculationRule->new({
314
        # undef,       undef,         undef     => 5
256
            branchcode => $branchcode,
315
        # undef,       undef,         $itemtype => 7
257
            categorycode => $categorycode,
316
        # undef,       $categorycode, undef     => 9
258
            itemtype => undef,
317
        # undef,       $categorycode, $itemtype => 11
259
            rule_name => 'fine',
318
        # $branchcode, undef,         undef     => 13
260
            rule_value   => 17,
319
        # $branchcode, undef,         $itemtype => 15
261
        })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => undef,");
320
        # $branchcode, $categorycode, undef     => 17
321
        ok(
322
            Koha::CirculationRule->new(
323
                {
324
                    branchcode   => $branchcode,
325
                    categorycode => $categorycode,
326
                    itemtype     => undef,
327
                    rule_name    => 'fine',
328
                    rule_value   => 17,
329
                }
330
              )->store,
331
            "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => undef,"
332
        );
262
        $rule = Koha::CirculationRules->get_effective_rule({
333
        $rule = Koha::CirculationRules->get_effective_rule({
263
            branchcode   => $branchcode,
334
            branchcode   => $branchcode,
264
            categorycode => $categorycode,
335
            categorycode => $categorycode,
265
            itemtype     => $itemtype,
336
            itemtype     => $itemtype,
266
            rule_name    => 'fine',
337
            rule_name    => 'fine',
267
            rule_value   => 18,
268
        });
338
        });
269
        _is_row_match(
339
        _is_row_match(
270
            $rule,
340
            $rule,
271
            {
341
            {
272
                branchcode => $branchcode,
342
                branchcode   => $branchcode,
273
                categorycode => $categorycode,
343
                categorycode => $categorycode,
274
                itemtype => undef
344
                itemtype     => undef,
345
                rule_name    => 'fine',
346
                rule_value   => 17,
275
            },
347
            },
276
            'When I attempt to get effective issuing rule,'
348
            'When I attempt to get effective issuing rule,'
277
           .' then the above one is returned.'
349
           .' then the above one is returned.'
278
        );
350
        );
279
351
280
        ok(Koha::CirculationRule->new({
352
        # undef,       undef,         undef     => 5
281
            branchcode => $branchcode,
353
        # undef,       undef,         $itemtype => 7
282
            categorycode => $categorycode,
354
        # undef,       $categorycode, undef     => 9
283
            itemtype => $itemtype,
355
        # undef,       $categorycode, $itemtype => 11
284
            rule_name => 'fine',
356
        # $branchcode, undef,         undef     => 13
285
            rule_value   => 19,
357
        # $branchcode, undef,         $itemtype => 15
286
        })->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype,");
358
        # $branchcode, $categorycode, undef     => 17
359
        # $branchcode, $categorycode, $itemtype => 19
360
        ok(
361
            Koha::CirculationRule->new(
362
                {
363
                    branchcode   => $branchcode,
364
                    categorycode => $categorycode,
365
                    itemtype     => $itemtype,
366
                    rule_name    => 'fine',
367
                    rule_value   => 19,
368
                }
369
              )->store,
370
            "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype,"
371
        );
287
        $rule = Koha::CirculationRules->get_effective_rule({
372
        $rule = Koha::CirculationRules->get_effective_rule({
288
            branchcode   => $branchcode,
373
            branchcode   => $branchcode,
289
            categorycode => $categorycode,
374
            categorycode => $categorycode,
290
            itemtype     => $itemtype,
375
            itemtype     => $itemtype,
291
            rule_name    => 'fine',
376
            rule_name    => 'fine',
292
            rule_value   => 20,
293
        });
377
        });
294
        _is_row_match(
378
        _is_row_match(
295
            $rule,
379
            $rule,
296
            {
380
            {
297
                branchcode => $branchcode,
381
                branchcode   => $branchcode,
298
                categorycode => $categorycode,
382
                categorycode => $categorycode,
299
                itemtype => $itemtype
383
                itemtype     => $itemtype,
384
                rule_name    => 'fine',
385
                rule_value   => 19,
300
            },
386
            },
301
            'When I attempt to get effective issuing rule,'
387
            'When I attempt to get effective issuing rule,'
302
           .' then the above one is returned.'
388
           .' then the above one is returned.'
303
- 

Return to bug 18936