From a6725939999a9429e1d3872932821e299ab72d1d Mon Sep 17 00:00:00 2001 From: Florent Mara Date: Tue, 24 May 2016 14:10:32 +1200 Subject: [PATCH] Bug 12178: Tests for changes to claimed serial status MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jonathan Druart Amended patch: Remove trailing spaces Signed-off-by: Kyle M Hall Signed-off-by: Kyle M Hall (cherry picked from commit c765d105096ac8c0bc5afd51eb212db54c7901e0) Signed-off-by: Frédéric Demians (cherry picked from commit a14999b7bdb745ccd18ea2ba719defa12fae8abd) Signed-off-by: Julian Maurice --- t/db_dependent/Serials.t | 56 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index a144ec98e3..ff6bed2826 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -15,7 +15,8 @@ use C4::Bookseller; use C4::Biblio; use C4::Budgets; use Koha::DateUtils; -use Test::More tests => 46; +use t::lib::TestBuilder; +use Test::More tests => 48; BEGIN { use_ok('C4::Serials'); @@ -27,6 +28,10 @@ my $dbh = C4::Context->dbh; $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; +# This could/should be used for all untested methods +my @methods = ('updateClaim'); +can_ok('C4::Serials', @methods); + my $booksellerid = C4::Bookseller::AddBookseller( { name => "my vendor", @@ -181,6 +186,55 @@ is(C4::Serials::HasSubscriptionExpired(), undef, 'test if the subscriptions has is(C4::Serials::GetLateOrMissingIssues(), undef, 'test getting last or missing issues'); +subtest 'test_updateClaim' => sub { + plan tests => 11; + + my $builder = t::lib::TestBuilder->new(); + # Given ... nothing much + # When ... Then ... + my $result_0 = C4::Serials::updateClaim(undef); + is($result_0, undef, 'Got the expected undef from update claim with nothin'); + + # Given ... 3 serial. 2 of them updated. + my $serialids_1 = [90980, 90981]; + my $claimdate_1 = '2001/01/13'; # arbitrary date some time in the past. + my $claim_count_1 = 5; + + $builder->build({ + source => 'Serial', + value => { serialid => $serialids_1->[0], serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3, biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1 }, + }); + $builder->build({ + source => 'Serial', + value => { serialid => $serialids_1->[1], serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3, biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1 }, + }); + $builder->build({ + source => 'Serial', + value => { serialid => 90982, serialseq => 'serialseq', subscriptionid => $subscriptionid, status => 3, biblionumber => 12345, claimdate => $claimdate_1, claims_count => $claim_count_1 }, + }); + + # When ... + my $result_1 = C4::Serials::updateClaim($serialids_1); + + # Then ... + is($result_1, 2, 'Got the expected 2 from update claim with 2 serial ids'); + + my @late_or_missing_issues_1_0 = C4::Serials::GetLateOrMissingIssues(undef, $serialids_1->[0]); + isnt($late_or_missing_issues_1_0[0]->{claimdate}, $claimdate_1, 'Got the expected first different claim date from update claim'); + is($late_or_missing_issues_1_0[0]->{claims_count}, $claim_count_1+1, 'Got the expected first claim count from update claim'); + is($late_or_missing_issues_1_0[0]->{status}, 7, 'Got the expected first claim status from update claim'); + + my @late_or_missing_issues_1_1 = C4::Serials::GetLateOrMissingIssues(undef, $serialids_1->[1]); + isnt($late_or_missing_issues_1_1[0]->{claimdate}, $claimdate_1, 'Got the expected second different claim date from update claim'); + is($late_or_missing_issues_1_1[0]->{claims_count}, $claim_count_1+1, 'Got the expected second claim count from update claim'); + is($late_or_missing_issues_1_1[0]->{status}, 7, 'Got the expected second claim status from update claim'); + + my @late_or_missing_issues_1_2 = C4::Serials::GetLateOrMissingIssues(undef, 90982); + is($late_or_missing_issues_1_2[0]->{claimdate}, '13/01/2001', 'Got the expected unchanged claim date from update claim'); + is($late_or_missing_issues_1_2[0]->{claims_count}, $claim_count_1, 'Got the expected unchanged claim count from update claim'); + is($late_or_missing_issues_1_2[0]->{status}, 3, 'Got the expected unchanged claim status from update claim'); +}; + is(C4::Serials::getsupplierbyserialid(),undef, 'test getting supplier idea'); is(C4::Serials::check_routing(), undef, 'test checking route'); -- 2.39.5