View | Details | Raw Unified | Return to bug 23971
Collapse All | Expand All

(-)a/t/db_dependent/Acquisition.t (-28 / +43 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use POSIX qw(strftime);
20
use POSIX qw(strftime);
21
21
22
use Test::More tests => 73;
22
use Test::More tests => 67;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::DateUtils qw(dt_from_string output_pref);
25
use Koha::DateUtils qw(dt_from_string output_pref);
Lines 125-132 sub _check_fields_of_orders { Link Here
125
my $schema = Koha::Database->new()->schema();
125
my $schema = Koha::Database->new()->schema();
126
$schema->storage->txn_begin();
126
$schema->storage->txn_begin();
127
127
128
t::lib::Mocks::mock_preference('AcqLog', 1);
129
130
# Creating some orders
128
# Creating some orders
131
my $bookseller = Koha::Acquisition::Bookseller->new(
129
my $bookseller = Koha::Acquisition::Bookseller->new(
132
    {
130
    {
Lines 150-158 ok( Link Here
150
);
148
);
151
ok( $basket = GetBasket($basketno), "GetBasket($basketno) returns $basket" );
149
ok( $basket = GetBasket($basketno), "GetBasket($basketno) returns $basket" );
152
150
153
my @create_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'ADD_BASKET', object => $basketno });
154
ok( scalar @create_logs == 1, 'Basket creation is logged');
155
156
my $bpid=AddBudgetPeriod({
151
my $bpid=AddBudgetPeriod({
157
        budget_period_startdate => '2008-01-01'
152
        budget_period_startdate => '2008-01-01'
158
        , budget_period_enddate => '2008-12-31'
153
        , budget_period_enddate => '2008-12-31'
Lines 416-442 $search_orders = SearchOrders({ Link Here
416
});
411
});
417
is( scalar (@$search_orders), 4, "SearchOrders with pending and ordered params gets only pending ordered orders. After closing the basket, orders are marked as 'ordered' (bug 11170)" );
412
is( scalar (@$search_orders), 4, "SearchOrders with pending and ordered params gets only pending ordered orders. After closing the basket, orders are marked as 'ordered' (bug 11170)" );
418
413
419
my @close_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basketno });
420
ok( scalar @close_logs == 1, 'Basket closure is logged');
421
C4::Acquisition::ReopenBasket($basketno);
422
my @reopen_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'REOPEN_BASKET', object => $basketno });
423
ok( scalar @reopen_logs == 1, 'Basket reopen is logged');
424
C4::Acquisition::CloseBasket($basketno, 1);
425
my @approve_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'APPROVE_BASKET', object => $basketno });
426
ok( scalar @approve_logs == 1, 'Basket approval is logged');
427
C4::Acquisition::ModBasket({
428
    basketno => $basketno,
429
    booksellerid => $booksellerid
430
});
431
my @mod_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET', object => $basketno });
432
ok( scalar @mod_logs == 1, 'Basket modify is logged');
433
C4::Acquisition::ModBasketHeader($basketno,"Test","","","",$booksellerid);
434
my @mod_header_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_HEADER', object => $basketno });
435
ok( scalar @mod_header_logs == 1, 'Basket header modify is logged');
436
C4::Acquisition::ModBasketUsers($basketno,(1));
437
my @mod_users_logs = Koha::ActionLogs->find({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_USERS', object => $basketno });
438
ok( scalar @mod_users_logs == 1, 'Basket users modify is logged');
439
440
#
414
#
441
# Test AddClaim
415
# Test AddClaim
442
#
416
#
Lines 925-928 subtest 'GetHistory - is_standing' => sub { Link Here
925
899
926
};
900
};
927
901
902
subtest 'Acquisition logging' => sub {
903
904
    plan tests => 6;
905
906
    t::lib::Mocks::mock_preference('AcqLog', 1);
907
908
    Koha::ActionLogs->delete;
909
    my $basketno = NewBasket( $booksellerid, 1 );
910
    my @create_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'ADD_BASKET', object => $basketno });
911
    is (scalar @create_logs, 1, 'Basket creation is logged');
912
913
    Koha::ActionLogs->delete;
914
    C4::Acquisition::CloseBasket($basketno);
915
    my @close_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basketno });
916
    is (scalar @close_logs, 1, 'Basket closure is logged');
917
    
918
    Koha::ActionLogs->delete;
919
    C4::Acquisition::ReopenBasket($basketno);
920
    my @reopen_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'REOPEN_BASKET', object => $basketno });
921
    is (scalar @reopen_logs, 1, 'Basket reopen is logged');
922
923
    Koha::ActionLogs->delete;
924
    C4::Acquisition::ModBasket({
925
        basketno => $basketno,
926
        booksellerid => $booksellerid
927
    });
928
    my @mod_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET', object => $basketno });
929
    is (scalar @mod_logs, 1, 'Basket modify is logged');
930
931
    Koha::ActionLogs->delete;
932
    C4::Acquisition::ModBasketHeader($basketno,"Test","","","",$booksellerid);
933
    my @mod_header_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_HEADER', object => $basketno });
934
    is (scalar @mod_header_logs, 1, 'Basket header modify is logged');
935
936
    Koha::ActionLogs->delete;
937
    C4::Acquisition::ModBasketUsers($basketno,(1));
938
    my @mod_users_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'MODIFY_BASKET_USERS', object => $basketno });
939
    is (scalar @mod_users_logs, 1, 'Basket users modify is logged');
940
941
    t::lib::Mocks::mock_preference('AcqLog', 0);
942
};
943
928
$schema->storage->txn_rollback();
944
$schema->storage->txn_rollback();
929
- 

Return to bug 23971