use C4::Biblio;
use C4::Budgets;
use Koha::DateUtils;
-use Test::More tests => 49;
+use Test::More tests => 48;
BEGIN {
use_ok('C4::Serials');
}
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;