Line 0
Link Here
|
0 |
- |
1 |
use Modern::Perl; |
|
|
2 |
use Test::More tests => 3; |
3 |
|
4 |
use C4::Serials; |
5 |
use Koha::Database; |
6 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
7 |
|
8 |
my $schema = Koha::Database->new->schema; |
9 |
$schema->storage->txn_begin; |
10 |
my $dbh = C4::Context->dbh; |
11 |
|
12 |
$dbh->do(q|DELETE FROM issues|); |
13 |
$dbh->do(q|DELETE FROM subscription|); |
14 |
|
15 |
my $branchcode = 'CPL'; |
16 |
my $record = MARC::Record->new(); |
17 |
my ( $biblionumber, $biblioitemnumber ) = C4::Biblio::AddBiblio($record, ''); |
18 |
|
19 |
# Create a new subscription |
20 |
my $subscriptionid_claims = C4::Serials::NewSubscription( |
21 |
undef, $branchcode, undef, undef, undef, $biblionumber, |
22 |
'2013-01-01', undef, undef, undef, undef, |
23 |
undef, undef, undef, undef, undef, undef, |
24 |
1, "notes",undef, '9999-01-01', undef, undef, |
25 |
undef, undef, 0, "intnotes", 0, |
26 |
undef, undef, 0, undef, '2013-12-31', 0 |
27 |
); |
28 |
|
29 |
# Verify and get the serial ID of the subscription |
30 |
my ( $totalissues, @serials ) = C4::Serials::GetSerials($subscriptionid_claims, 1); |
31 |
|
32 |
C4::Serials::updateClaim( $serials[0]->{serialid} ); # Updating the claim |
33 |
# sort the result to separate the CLAIMED and EXPECTED status |
34 |
@serials = sort { $a->{serialid} <=> $b->{serialid} } @serials; |
35 |
|
36 |
# Verify if serial IDs are correctly generated |
37 |
( $totalissues, @serials ) = C4::Serials::GetSerials($subscriptionid_claims); |
38 |
|
39 |
is ( scalar(@serials), 2, "le test est terminé" ); # Gives the length of the @serials |
40 |
|
41 |
is ( ($serials[0]->{status}), C4::Serials::CLAIMED, "test CLAIMED" ); |
42 |
is ( ($serials[1]->{status}), C4::Serials::EXPECTED, "test EXPECTED" ); |