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 => 68; |
13 |
use Test::More tests => 72; |
12 |
|
14 |
|
13 |
BEGIN { |
15 |
BEGIN { |
14 |
use_ok('C4::Acquisition'); |
16 |
use_ok('C4::Acquisition'); |
Lines 845-848
is( $nonexistent_order, undef, 'GetOrder returns undef if no ordernumber is give
Link Here
|
845 |
$nonexistent_order = GetOrder( 424242424242 ); |
847 |
$nonexistent_order = GetOrder( 424242424242 ); |
846 |
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' ); |
848 |
is( $nonexistent_order, undef, 'GetOrder returns undef if a nonexistent ordernumber is given' ); |
847 |
|
849 |
|
|
|
850 |
# |
851 |
# test DelOrder |
852 |
# use: |
853 |
# &DelOrder($ordernumber,$biblionumber); |
854 |
|
855 |
# create 3 items on the same record and link 2 of them to the order |
856 |
# we use the order $ordernumbers[2], which has the status 'complete' and no cancellation date before we try to delete it |
857 |
|
858 |
# Add a branch |
859 |
my $b1 = { |
860 |
add => 1, |
861 |
branchcode => 'BRA', |
862 |
branchname => 'BranchA', |
863 |
branchaddress1 => 'adr1A', |
864 |
branchaddress2 => 'adr2A', |
865 |
branchaddress3 => 'adr3A', |
866 |
branchzip => 'zipA', |
867 |
branchcity => 'cityA', |
868 |
branchstate => 'stateA', |
869 |
branchcountry => 'countryA', |
870 |
branchphone => 'phoneA', |
871 |
branchfax => 'faxA', |
872 |
branchemail => 'emailA', |
873 |
branchurl => 'urlA', |
874 |
branchip => 'ipA', |
875 |
branchprinter => undef, |
876 |
branchnotes => 'noteA', |
877 |
opac_info => 'opacA' |
878 |
}; |
879 |
ModBranch($b1); |
880 |
|
881 |
my ($item_bibnum1, $item_bibitemnum1, $itemnumber1) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); |
882 |
my ($item_bibnum2, $item_bibitemnum2, $itemnumber2) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); |
883 |
my ($item_bibnum3, $item_bibitemnum3, $itemnumber3) = AddItem({ homebranch => 'BRA', holdingbranch => 'BRA' } , $biblionumber2); |
884 |
NewOrderItem ($itemnumber1, $ordernumbers[2]); |
885 |
NewOrderItem ($itemnumber2, $ordernumbers[2]); |
886 |
|
887 |
# If no ordernumber is passed, the function returns undef and does not try to update database |
888 |
my $return_DelOrder = DelOrder (); |
889 |
is($return_DelOrder , undef, 'DelOrder returns undef with no param'); |
890 |
# Cancel the order with the given order, by filling the datecancellationprinted and orderstatus fields. |
891 |
DelOrder ($ordernumbers[2],$biblionumber2); |
892 |
$order3 = GetOrder( $ordernumbers[2] ); |
893 |
ok(($order3->{'orderstatus'} eq 'cancelled')&& (defined $order3->{'datecancellationprinted'}),'DelOrders update orderstatus and fill datecancellationprinted fields'); |
894 |
|
895 |
# All the items linked with that order are deleted (in items, not in aqorders_items by the way) |
896 |
ok(!defined GetItem($itemnumber1) && !defined GetItem($itemnumber2), "DelOrder deletes items linked with order in items table"); |
897 |
|
898 |
# Other items (created manually) are not deleted. |
899 |
is(GetItem($itemnumber3)->{biblionumber},$biblionumber2, "DelOrder does not delete item created manually"); |
900 |
|
848 |
$dbh->rollback; |
901 |
$dbh->rollback; |
849 |
- |
|
|