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

(-)a/t/db_dependent/Serials.t (-2 / +56 lines)
Lines 14-20 use C4::Debug; Link Here
14
use C4::Bookseller;
14
use C4::Bookseller;
15
use C4::Biblio;
15
use C4::Biblio;
16
use C4::Budgets;
16
use C4::Budgets;
17
use Test::More tests => 35;
17
use Koha::DateUtils;
18
use Test::More tests => 44;
18
19
19
BEGIN {
20
BEGIN {
20
    use_ok('C4::Serials');
21
    use_ok('C4::Serials');
Lines 180-183 is(C4::Serials::check_routing(), undef, 'test checking route'); Link Here
180
181
181
is(C4::Serials::addroutingmember(),undef, 'test adding route member');
182
is(C4::Serials::addroutingmember(),undef, 'test adding route member');
182
183
184
185
# Unit tests for statuses management (Bug 11689)
186
$subscriptionid = NewSubscription(
187
    undef,      "",     undef, undef, $budget_id, $biblionumber,
188
    '2013-01-01', $frequency_id, undef, undef,  undef,
189
    undef,      undef,  undef, undef, undef, undef,
190
    1,          "notes",undef, '2013-01-01', undef, $pattern_id,
191
    undef,       undef,  0,    "intnotes",  0,
192
    undef, undef, 0,          undef,         '2013-12-31', 0
193
);
194
my $total_issues;
195
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
196
is( $total_issues, 1, "NewSubscription created a first serial" );
197
is( @serials, 1, "GetSerials returns the serial" );
198
my $subscription = C4::Serials::GetSubscription($subscriptionid);
199
my $pattern = C4::Serials::Numberpattern::GetSubscriptionNumberpattern($subscription->{numberpattern});
200
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
201
my $publisheddate = output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 });
202
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
203
my $nextpublisheddate = C4::Serials::GetNextDate($subscription, $publisheddate, 1);
204
my @statuses = qw( 2 2 3 3 3 3 3 4 4 41 42 43 44 5 );
205
# Add 14 serials
206
my $counter = 0;
207
for my $status ( @statuses ) {
208
    my $serialseq = "No.".$counter;
209
    my ( $expected_serial ) = GetSerials2( $subscriptionid, 1 );
210
    C4::Serials::ModSerialStatus( $expected_serial->{serialid}, $serialseq, $publisheddate, $publisheddate, $statuses[$counter], 'an useless note' );
211
    $counter++;
212
}
213
# Here we have 15 serials with statuses : 2*2 + 5*3 + 2*4 + 1*41 + 1*42 + 1*43 + 1*44 + 1*5 + 1*1
214
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid );
215
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" );
216
my @arrived_missing = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () } @serials;
217
my @others = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? () : $_ } @serials;
218
is( @arrived_missing, 5, "GetSerials returns 5 arrived/missing by default" );
219
is( @others, 6, "GetSerials returns all serials not arrived and not missing" );
220
221
( $total_issues, @serials ) = C4::Serials::GetSerials( $subscriptionid, 10 );
222
is( $total_issues, @statuses + 1, "GetSerials returns total_issues" );
223
@arrived_missing = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? $_ : () } @serials;
224
@others = map { my $status = $_->{status}; ( grep { /^$status$/ } qw( 2 4 41 42 43 44 5 ) ) ? () : $_ } @serials;
225
is( @arrived_missing, 9, "GetSerials returns all arrived/missing if count given" );
226
is( @others, 6, "GetSerials returns all serials not arrived and not missing if count given" );
227
228
$subscription = C4::Serials::GetSubscription($subscriptionid); # Retrieve the updated subscription
229
230
my @serialseqs;
231
for my $am ( reverse @arrived_missing ) {
232
    if ( grep {/^$am->{status}$/} qw( 4 41 42 43 44 5 ) ) {
233
        push @serialseqs, $am->{serialseq}
234
    }
235
}
236
is( $subscription->{missinglist}, 'not issued ' . join('; ', @serialseqs), "subscription missinglist is updated after ModSerialStatus" );
237
183
$dbh->rollback;
238
$dbh->rollback;
184
- 

Return to bug 11689