Lines 1-5
Link Here
|
1 |
use Modern::Perl; |
1 |
use Modern::Perl; |
2 |
use Test::More tests => 108; |
2 |
use Test::More tests => 120; |
3 |
|
3 |
|
4 |
BEGIN { |
4 |
BEGIN { |
5 |
use_ok('C4::Budgets') |
5 |
use_ok('C4::Budgets') |
Lines 9-14
use C4::Biblio;
Link Here
|
9 |
use C4::Bookseller; |
9 |
use C4::Bookseller; |
10 |
use C4::Acquisition; |
10 |
use C4::Acquisition; |
11 |
use C4::Dates; |
11 |
use C4::Dates; |
|
|
12 |
use C4::Members qw( AddMember ); |
12 |
|
13 |
|
13 |
use YAML; |
14 |
use YAML; |
14 |
my $dbh = C4::Context->dbh; |
15 |
my $dbh = C4::Context->dbh; |
Lines 95-100
is( @$budgetperiods, 0, 'GetBudgetPeriods returns the correct number of budget p
Link Here
|
95 |
# Budget : |
96 |
# Budget : |
96 |
# |
97 |
# |
97 |
|
98 |
|
|
|
99 |
# The budget hierarchy will be: |
100 |
# budget_1 |
101 |
# budget_11 |
102 |
# budget_111 |
103 |
# budget_12 |
104 |
# budget_2 |
105 |
# budget_21 |
106 |
|
98 |
is( AddBudget(), undef, 'AddBuget without argument returns undef' ); |
107 |
is( AddBudget(), undef, 'AddBuget without argument returns undef' ); |
99 |
my $budgets = GetBudgets(); |
108 |
my $budgets = GetBudgets(); |
100 |
is( @$budgets, 0, 'GetBudgets returns the correct number of budgets' ); |
109 |
is( @$budgets, 0, 'GetBudgets returns the correct number of budgets' ); |
Lines 512-517
for my $new_budget ( @new_budgets ) {
Link Here
|
512 |
is( $new_budget->{budget_amount} + 0, $new_budget_amount_should_be, "MoveOrders updated the budget amount with the previous unspent budget (for budget $new_budget->{budget_code})" ); |
521 |
is( $new_budget->{budget_amount} + 0, $new_budget_amount_should_be, "MoveOrders updated the budget amount with the previous unspent budget (for budget $new_budget->{budget_code})" ); |
513 |
} |
522 |
} |
514 |
|
523 |
|
|
|
524 |
# Test SetOwnerToFundHierarchy |
525 |
|
526 |
my $categorycode = 'S'; |
527 |
my $branchcode = 'CPL'; |
528 |
my $john_doe = C4::Members::AddMember( |
529 |
cardnumber => '123456', |
530 |
firstname => 'John', |
531 |
surname => 'Doe', |
532 |
categorycode => $categorycode, |
533 |
branchcode => $branchcode, |
534 |
dateofbirth => '', |
535 |
dateexpiry => '9999-12-31', |
536 |
userid => 'john.doe' |
537 |
); |
538 |
|
539 |
C4::Budgets::SetOwnerToFundHierarchy( $budget_id1, $john_doe ); |
540 |
is( C4::Budgets::GetBudget($budget_id1)->{budget_owner_id}, |
541 |
$john_doe, "SetOwnerToFundHierarchy should have set John Doe for budget 1 ($budget_id1)" ); |
542 |
is( C4::Budgets::GetBudget($budget_id11)->{budget_owner_id}, |
543 |
$john_doe, "SetOwnerToFundHierarchy should have set John Doe for budget 11 ($budget_id11)" ); |
544 |
is( C4::Budgets::GetBudget($budget_id111)->{budget_owner_id}, |
545 |
$john_doe, "SetOwnerToFundHierarchy should have set John Doe for budget 111 ($budget_id111)" ); |
546 |
is( C4::Budgets::GetBudget($budget_id12)->{budget_owner_id}, |
547 |
$john_doe, "SetOwnerToFundHierarchy should have set John Doe for budget 12 ($budget_id12 )" ); |
548 |
is( C4::Budgets::GetBudget($budget_id2)->{budget_owner_id}, |
549 |
undef, "SetOwnerToFundHierarchy should not have set an owner for budget 2 ($budget_id2)" ); |
550 |
is( C4::Budgets::GetBudget($budget_id21)->{budget_owner_id}, |
551 |
undef, "SetOwnerToFundHierarchy should not have set an owner for budget 21 ($budget_id21)" ); |
552 |
|
553 |
my $jane_doe = C4::Members::AddMember( |
554 |
cardnumber => '789012', |
555 |
firstname => 'Jane', |
556 |
surname => 'Doe', |
557 |
categorycode => $categorycode, |
558 |
branchcode => $branchcode, |
559 |
dateofbirth => '', |
560 |
dateexpiry => '9999-12-31', |
561 |
userid => 'jane.doe' |
562 |
); |
563 |
|
564 |
C4::Budgets::SetOwnerToFundHierarchy( $budget_id11, $jane_doe ); |
565 |
is( C4::Budgets::GetBudget($budget_id1)->{budget_owner_id}, |
566 |
$john_doe, "SetOwnerToFundHierarchy should have set John Doe $john_doe for budget 1 ($budget_id1)" ); |
567 |
is( C4::Budgets::GetBudget($budget_id11)->{budget_owner_id}, |
568 |
$jane_doe, "SetOwnerToFundHierarchy should have set John Doe $jane_doe for budget 11 ($budget_id11)" ); |
569 |
is( C4::Budgets::GetBudget($budget_id111)->{budget_owner_id}, |
570 |
$jane_doe, "SetOwnerToFundHierarchy should have set John Doe $jane_doe for budget 111 ($budget_id111)" ); |
571 |
is( C4::Budgets::GetBudget($budget_id12)->{budget_owner_id}, |
572 |
$john_doe, "SetOwnerToFundHierarchy should have set John Doe $john_doe for budget 12 ($budget_id12 )" ); |
573 |
is( C4::Budgets::GetBudget($budget_id2)->{budget_owner_id}, |
574 |
undef, "SetOwnerToFundHierarchy should have set John Doe $john_doe for budget 2 ($budget_id2)" ); |
575 |
is( C4::Budgets::GetBudget($budget_id21)->{budget_owner_id}, |
576 |
undef, "SetOwnerToFundHierarchy should have set John Doe $john_doe for budget 21 ($budget_id21)" ); |
577 |
|
515 |
sub _get_dependencies { |
578 |
sub _get_dependencies { |
516 |
my ($budget_hierarchy) = @_; |
579 |
my ($budget_hierarchy) = @_; |
517 |
my $graph; |
580 |
my $graph; |
518 |
- |
|
|