Bug 12748: Code tidy
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 44062c07b7)
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
This commit is contained in:
parent
67b4f25a69
commit
69e4c39c21
|
|
@ -2695,9 +2695,9 @@ sub _can_do_on_subscription {
|
|||
|
||||
=cut
|
||||
|
||||
sub findSerialsByStatus{
|
||||
my($status, $subscriptionid) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
sub findSerialsByStatus {
|
||||
my ( $status, $subscriptionid ) = @_;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = q| SELECT * from serial
|
||||
WHERE status = ?
|
||||
AND subscriptionid = ?
|
||||
|
|
@ -2705,6 +2705,7 @@ sub findSerialsByStatus{
|
|||
my $serials = $dbh->selectall_arrayref( $query, { Slice => {} }, $status, $subscriptionid );
|
||||
return @$serials;
|
||||
}
|
||||
|
||||
1;
|
||||
__END__
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use C4::Bookseller;
|
|||
use C4::Biblio;
|
||||
use C4::Budgets;
|
||||
use Koha::DateUtils;
|
||||
use Test::More tests => 49;
|
||||
use Test::More tests => 48;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Serials');
|
||||
|
|
@ -248,20 +248,28 @@ for my $am ( @arrived_missing ) {
|
|||
}
|
||||
is( $subscription->{missinglist}, join('; ', @serialseqs), "subscription missinglist is updated after ModSerialStatus" );
|
||||
|
||||
my ( $expected_serial ) = GetSerials2( $subscriptionid, [1] );
|
||||
#Find serialid for serial with status Expected
|
||||
my $serialexpected = (C4::Serials::findSerialsByStatus(1,$subscriptionid))[0];
|
||||
#delete serial with status Expected
|
||||
C4::Serials::ModSerialStatus( $serialexpected->{serialid},$serialexpected->{serialseq},$publisheddate,$publisheddate, $publisheddate,'1','an useless note');
|
||||
@serialsByStatus = C4::Serials::findSerialsByStatus(1,$subscriptionid);
|
||||
is (@serialsByStatus,1,"ModSerialStatus delete corectly serial expected and create another if not exist");
|
||||
# add 1 serial with status=Expected 1
|
||||
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
|
||||
#Now we have two serials it have status expected
|
||||
#put status delete for last serial
|
||||
C4::Serials::ModSerialStatus( $serialexpected->{serialid},$serialexpected->{serialseq},$publisheddate,$publisheddate, $publisheddate,'1','an useless note');
|
||||
#try if create or note another serial with status is expected
|
||||
@serialsByStatus = C4::Serials::findSerialsByStatus(1,$subscriptionid);
|
||||
is(@serialsByStatus,1,"ModSerialStatus delete corectly serial expected and not create another if exist");
|
||||
subtest "Do not generate an expected if one already exists" => sub {
|
||||
plan tests => 2;
|
||||
my ($expected_serial) = GetSerials2( $subscriptionid, [1] );
|
||||
|
||||
#Find serialid for serial with status Expected
|
||||
my $serialexpected = ( C4::Serials::findSerialsByStatus( 1, $subscriptionid ) )[0];
|
||||
|
||||
#delete serial with status Expected
|
||||
C4::Serials::ModSerialStatus( $serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
|
||||
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid );
|
||||
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and create another if not exist" );
|
||||
|
||||
# add 1 serial with status=Expected 1
|
||||
C4::Serials::ModSerialStatus( $expected_serial->{serialid}, 'NO.20', $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
|
||||
|
||||
#Now we have two serials it have status expected
|
||||
#put status delete for last serial
|
||||
C4::Serials::ModSerialStatus( $serialexpected->{serialid}, $serialexpected->{serialseq}, $publisheddate, $publisheddate, $publisheddate, '1', 'an useless note' );
|
||||
|
||||
#try if create or not another serial with status is expected
|
||||
@serialsByStatus = C4::Serials::findSerialsByStatus( 1, $subscriptionid );
|
||||
is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" );
|
||||
};
|
||||
|
||||
$dbh->rollback;
|
||||
|
|
|
|||
Loading…
Reference in New Issue