Bug 15009 - Adds unit tests for C4::Budget::GetBudgetAuthCats
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
(cherry picked from commit 1a9ca84293)
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
This commit is contained in:
parent
76aba15a35
commit
5685fb44e6
|
|
@ -1,5 +1,5 @@
|
|||
use Modern::Perl;
|
||||
use Test::More tests => 122;
|
||||
use Test::More tests => 125;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Budgets')
|
||||
|
|
@ -589,6 +589,55 @@ is( C4::Budgets::GetBudget($budget_id2)->{budget_owner_id},
|
|||
is( C4::Budgets::GetBudget($budget_id21)->{budget_owner_id},
|
||||
undef, "SetOwnerToFundHierarchy should have set John Doe $john_doe for budget 21 ($budget_id21)" );
|
||||
|
||||
# Test GetBudgetAuthCats
|
||||
|
||||
my $budgetPeriodId = 1;
|
||||
|
||||
my $bdgts = GetBudgets();
|
||||
my $i = 0;
|
||||
for my $budget ( @{$bdgts} )
|
||||
{
|
||||
$budget->{sort1_authcat} = "sort1_authcat_$i";
|
||||
$budget->{sort2_authcat} = "sort2_authcat_$i";
|
||||
$budget->{budget_period_id} = $budgetPeriodId;
|
||||
ModBudget( $budget );
|
||||
$i++;
|
||||
}
|
||||
|
||||
my $authCat = GetBudgetAuthCats($budgetPeriodId);
|
||||
|
||||
is( scalar @{$authCat}, $i * 2, "GetBudgetAuthCats returns only non-empty sorting categories (no empty authCat in db)" );
|
||||
|
||||
$i = 0;
|
||||
for my $budget ( @{$bdgts} )
|
||||
{
|
||||
$budget->{sort1_authcat} = "sort1_authcat_$i";
|
||||
$budget->{sort2_authcat} = "";
|
||||
$budget->{budget_period_id} = $budgetPeriodId;
|
||||
ModBudget( $budget );
|
||||
$i++;
|
||||
}
|
||||
|
||||
$authCat = GetBudgetAuthCats($budgetPeriodId);
|
||||
|
||||
is( scalar @{$authCat}, $i, "GetBudgetAuthCats returns only non-empty sorting categories (empty sort2_authcat on all records)" );
|
||||
|
||||
$i = 0;
|
||||
for my $budget ( @{$bdgts} )
|
||||
{
|
||||
$budget->{sort1_authcat} = "";
|
||||
$budget->{sort2_authcat} = "";
|
||||
$budget->{budget_period_id} = $budgetPeriodId;
|
||||
ModBudget( $budget );
|
||||
$i++;
|
||||
}
|
||||
|
||||
$authCat = GetBudgetAuthCats($budgetPeriodId);
|
||||
|
||||
is( scalar @{$authCat}, 0, "GetBudgetAuthCats returns only non-empty sorting categories (all empty)" );
|
||||
|
||||
# /Test GetBudgetAuthCats
|
||||
|
||||
sub _get_dependencies {
|
||||
my ($budget_hierarchy) = @_;
|
||||
my $graph;
|
||||
|
|
|
|||
Loading…
Reference in New Issue