Lines 7-14
use Modern::Perl;
Link Here
|
7 |
use POSIX qw(strftime); |
7 |
use POSIX qw(strftime); |
8 |
|
8 |
|
9 |
use C4::Bookseller qw( GetBookSellerFromId ); |
9 |
use C4::Bookseller qw( GetBookSellerFromId ); |
|
|
10 |
use C4::Items qw (AddItem GetItem); |
11 |
use C4::Branch qw (ModBranch); |
10 |
|
12 |
|
11 |
use Test::More tests => 79; |
13 |
use Test::More tests => 83; |
12 |
|
14 |
|
13 |
BEGIN { |
15 |
BEGIN { |
14 |
use_ok('C4::Acquisition'); |
16 |
use_ok('C4::Acquisition'); |
Lines 925-928
is( $nonexistent_order, undef, 'GetOrder returns undef if no ordernumber is give
Link Here
|
925 |
$nonexistent_order = GetOrder( 424242424242 ); |
927 |
$nonexistent_order = GetOrder( 424242424242 ); |
926 |
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' ); |
928 |
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' ); |
927 |
|
929 |
|
|
|
930 |
# |
931 |
# test DelOrder |
932 |
# use: |
933 |
# &DelOrder($ordernumber,$biblionumber); |
934 |
|
935 |
# create 3 items on the same record and link 2 of them to the order |
936 |
# we use the order $ordernumbers[2], which has the status 'complete' and no cancellation date before we try to delete it |
937 |
|
938 |
# Add a branch |
939 |
my $b1 = { |
940 |
add => 1, |
941 |
branchcode => 'BRA', |
942 |
branchname => 'BranchA', |
943 |
branchaddress1 => 'adr1A', |
944 |
branchaddress2 => 'adr2A', |
945 |
branchaddress3 => 'adr3A', |
946 |
branchzip => 'zipA', |
947 |
branchcity => 'cityA', |
948 |
branchstate => 'stateA', |
949 |
branchcountry => 'countryA', |
950 |
branchphone => 'phoneA', |
951 |
branchfax => 'faxA', |
952 |
branchemail => 'emailA', |
953 |
branchurl => 'urlA', |
954 |
branchip => 'ipA', |
955 |
branchprinter => undef, |
956 |
branchnotes => 'noteA', |
957 |
opac_info => 'opacA' |
958 |
}; |
959 |
ModBranch($b1); |
960 |
|
961 |
my ($item_bibnum1, $item_bibitemnum1, $itemnumber1) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); |
962 |
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); |
963 |
my ($item_bibnum3, $item_bibitemnum3, $itemnumber3) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); |
964 |
NewOrderItem ($itemnumber1, $ordernumbers[2]); |
965 |
NewOrderItem ($itemnumber2, $ordernumbers[2]); |
966 |
|
967 |
# If no ordernumber is passed, the function returns undef and does not try to update database |
968 |
my $return_DelOrder = DelOrder (); |
969 |
is($return_DelOrder , undef, 'DelOrder returns undef with no param'); |
970 |
# Cancel the order with the given order, by filling the datecancellationprinted and orderstatus fields. |
971 |
DelOrder ($ordernumbers[2],$biblionumber2); |
972 |
$order3 = GetOrder( $ordernumbers[2] ); |
973 |
ok(($order3->{'orderstatus'} eq 'cancelled')&& (defined $order3->{'datecancellationprinted'}),'DelOrders update orderstatus and fill datecancellationprinted fields'); |
974 |
|
975 |
# All the items linked with that order are deleted (in items, not in aqorders_items by the way) |
976 |
ok(!defined GetItem($itemnumber1) && !defined GetItem($itemnumber2), "DelOrder deletes items linked with order in items table"); |
977 |
|
978 |
# Other items (created manually) are not deleted. |
979 |
is(GetItem($itemnumber3)->{biblionumber},$biblionumber2, "DelOrder does not delete item created manually"); |
980 |
|
928 |
$dbh->rollback; |
981 |
$dbh->rollback; |
929 |
- |
|
|