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

(-)a/t/db_dependent/Letters/TemplateToolkit.t (-31 / +30 lines)
Lines 65-102 my $library = $builder->build( { source => 'Branch' } ); Link Here
65
my $patron  = $builder->build( { source => 'Borrower' } );
65
my $patron  = $builder->build( { source => 'Borrower' } );
66
my $patron2 = $builder->build( { source => 'Borrower' } );
66
my $patron2 = $builder->build( { source => 'Borrower' } );
67
67
68
my $biblio = Koha::Biblio->new(
68
my $item = $builder->build_sample_item();
69
my $hold = $builder->build_object(
69
    {
70
    {
70
        title => 'Test Biblio'
71
        class => 'Koha::Holds',
71
    }
72
        value => {
72
)->store();
73
            borrowernumber => $patron->{borrowernumber},
73
74
            biblionumber   => $item->biblionumber
74
my $biblioitem = Koha::Biblioitem->new(
75
        }
75
    {
76
        biblionumber => $biblio->id()
77
    }
76
    }
78
)->store();
77
);
79
78
80
my $item = Koha::Item->new(
79
my $news = $builder->build_object(
81
    {
80
    {
82
        biblionumber     => $biblio->id(),
81
        class => 'Koha::News',
83
        biblioitemnumber => $biblioitem->id()
82
        value => { title => 'a news title', content => 'a news content' }
84
    }
83
    }
85
)->store();
84
);
86
85
my $serial       = $builder->build_object( { class => 'Koha::Serials' } );
87
my $hold = Koha::Hold->new(
86
my $subscription = $builder->build_object( { class => 'Koha::Subscriptions' } );
87
my $suggestion   = $builder->build_object( { class => 'Koha::Suggestions' } );
88
my $checkout     = $builder->build_object(
89
    { class => 'Koha::Checkouts', value => { itemnumber => $item->id } } );
90
my $modification = $builder->build_object(
88
    {
91
    {
89
        borrowernumber => $patron->{borrowernumber},
92
        class => 'Koha::Patron::Modifications',
90
        biblionumber   => $biblio->id()
93
        value => {
94
            verification_token => "TEST",
95
            changed_fields     => 'firstname,surname'
96
        }
91
    }
97
    }
92
)->store();
98
);
93
94
my $news         = Koha::NewsItem->new({ title => 'a news title', content => 'a news content'})->store();
95
my $serial       = Koha::Serial->new()->store();
96
my $subscription = Koha::Subscription->new()->store();
97
my $suggestion   = Koha::Suggestion->new()->store();
98
my $checkout     = Koha::Checkout->new( { itemnumber => $item->id() } )->store();
99
my $modification = Koha::Patron::Modification->new( { verification_token => "TEST", changed_fields => 'firstname,surname' } )->store();
100
99
101
my $prepared_letter;
100
my $prepared_letter;
102
101
Lines 143-153 $prepared_letter = GetPreparedLetter( Link Here
143
        module      => 'test',
142
        module      => 'test',
144
        letter_code => 'TEST_BIBLIO',
143
        letter_code => 'TEST_BIBLIO',
145
        tables      => {
144
        tables      => {
146
            biblio => $biblio->id(),
145
            biblio => $item->biblionumber,
147
        },
146
        },
148
    )
147
    )
149
);
148
);
150
is( $prepared_letter->{content}, $biblio->id, 'Biblio object used correctly' );
149
is( $prepared_letter->{content}, $item->biblionumber, 'Biblio object used correctly' );
151
150
152
$sth->execute( "TEST_LIBRARY", "[% branch.id %]" );
151
$sth->execute( "TEST_LIBRARY", "[% branch.id %]" );
153
$prepared_letter = GetPreparedLetter(
152
$prepared_letter = GetPreparedLetter(
Lines 191-197 $prepared_letter = GetPreparedLetter( Link Here
191
        module      => 'test',
190
        module      => 'test',
192
        letter_code => 'TEST_HOLD',
191
        letter_code => 'TEST_HOLD',
193
        tables      => {
192
        tables      => {
194
            reserves => { borrowernumber => $patron->{borrowernumber}, biblionumber => $biblio->id() },
193
            reserves => { borrowernumber => $patron->{borrowernumber}, biblionumber => $item->biblionumber },
195
        },
194
        },
196
    )
195
    )
197
);
196
);
Lines 203-209 eval { Link Here
203
            module      => 'test',
202
            module      => 'test',
204
            letter_code => 'TEST_HOLD',
203
            letter_code => 'TEST_HOLD',
205
            tables      => {
204
            tables      => {
206
                reserves => [ $patron->{borrowernumber}, $biblio->id() ],
205
                reserves => [ $patron->{borrowernumber}, $item->biblionumber ],
207
            },
206
            },
208
        )
207
        )
209
    )
208
    )
Lines 219-226 $prepared_letter = GetPreparedLetter( Link Here
219
        tables      => {
218
        tables      => {
220
            'branches'    => $library,
219
            'branches'    => $library,
221
            'borrowers'   => $patron,
220
            'borrowers'   => $patron,
222
            'biblio'      => $biblio->id,
221
            'biblio'      => $item->biblionumber,
223
            'biblioitems' => $biblioitem->id,
222
            'biblioitems' => $item->biblioitemnumber,
224
            'reserves'    => $hold->unblessed,
223
            'reserves'    => $hold->unblessed,
225
            'items'       => $hold->itemnumber,
224
            'items'       => $hold->itemnumber,
226
        }
225
        }
(-)a/t/db_dependent/Serials.t (-12 / +44 lines)
Lines 250-282 subtest 'test_updateClaim' => sub { Link Here
250
    is($result_0, undef, 'Got the expected undef from update claim with nothin');
250
    is($result_0, undef, 'Got the expected undef from update claim with nothin');
251
251
252
    # Given ... 3 serial. 2 of them updated.
252
    # Given ... 3 serial. 2 of them updated.
253
    my $serialids_1   = [90980, 90981];
254
    my $claimdate_1   = dt_from_string('2001-01-13'); # arbitrary date some time in the past.
253
    my $claimdate_1   = dt_from_string('2001-01-13'); # arbitrary date some time in the past.
255
    my $claim_count_1 = 5;
254
    my $claim_count_1 = 5;
256
    Koha::Serial->new( { serialid => $serialids_1->[0], serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3,
255
    my $biblio = $builder->build_sample_biblio;
257
                         biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1, } )->store();
256
    my $serial1 = $builder->build_object(
258
    Koha::Serial->new( { serialid => $serialids_1->[1], serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3,
257
        {
259
                         biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1,  } )->store();
258
            class => 'Koha::Serials',
260
    Koha::Serial->new( { serialid => 90982, serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3,
259
            value => {
261
                         biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1,  } )->store();
260
                serialseq      => 'serialseq',
261
                subscriptionid => $subscriptionid,
262
                status         => 3,
263
                biblionumber   => $biblio->biblionumber,
264
                claimdate      => $claimdate_1,
265
                claims_count   => $claim_count_1,
266
            }
267
        }
268
    );
269
    my $serial2 = $builder->build_object(
270
        {
271
            class => 'Koha::Serials',
272
            value => {
273
                serialseq      => 'serialseq',
274
                subscriptionid => $subscriptionid,
275
                status         => 3,
276
                biblionumber   => $biblio->biblionumber,
277
                claimdate      => $claimdate_1,
278
                claims_count   => $claim_count_1,
279
            }
280
        }
281
    );
282
    my $serial3 = $builder->build_object(
283
        {
284
            class => 'Koha::Serials',
285
            value => {
286
                serialseq      => 'serialseq',
287
                subscriptionid => $subscriptionid,
288
                status         => 3,
289
                biblionumber   => $biblio->biblionumber,
290
                claimdate      => $claimdate_1,
291
                claims_count   => $claim_count_1,
292
            }
293
        }
294
    );
262
295
263
    # When ...
296
    # When ...
264
    my $result_1 = C4::Serials::updateClaim($serialids_1);
297
    my $result_1 = C4::Serials::updateClaim([$serial1->serialid, $serial2->serialid]);
265
298
266
    # Then ...
299
    # Then ...
267
    is($result_1, 2, 'Got the expected 2 from update claim with 2 serial ids');
300
    is($result_1, 2, 'Got the expected 2 from update claim with 2 serial ids');
268
301
269
    my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues(undef, $serialids_1->[0]);
302
    my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues(undef, $serial1->serialid);
270
    is($late_or_missing_issues_1_0[0]->{claimdate}, $today, 'Got the expected first different claim date from update claim');
303
    is($late_or_missing_issues_1_0[0]->{claimdate}, $today, 'Got the expected first different claim date from update claim');
271
    is($late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1+1, 'Got the expected first claim count from update claim');
304
    is($late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1+1, 'Got the expected first claim count from update claim');
272
    is($late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim');
305
    is($late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim');
273
306
274
    my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues(undef, $serialids_1->[1]);
307
    my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues(undef, $serial2->serialid);
275
    is($late_or_missing_issues_1_1[0]->{claimdate}, $today, 'Got the expected second different claim date from update claim');
308
    is($late_or_missing_issues_1_1[0]->{claimdate}, $today, 'Got the expected second different claim date from update claim');
276
    is($late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1+1, 'Got the expected second claim count from update claim');
309
    is($late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1+1, 'Got the expected second claim count from update claim');
277
    is($late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim');
310
    is($late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim');
278
311
279
    my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues(undef, 90982);
312
    my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues(undef, $serial3->serialid);
280
    is($late_or_missing_issues_1_2[0]->{claimdate}, output_pref({ dt => $claimdate_1, dateonly => 1}), 'Got the expected unchanged claim date from update claim');
313
    is($late_or_missing_issues_1_2[0]->{claimdate}, output_pref({ dt => $claimdate_1, dateonly => 1}), 'Got the expected unchanged claim date from update claim');
281
    is($late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, 'Got the expected unchanged claim count from update claim');
314
    is($late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, 'Got the expected unchanged claim count from update claim');
282
    is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim');
315
    is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim');
283
- 

Return to bug 21901