Lines 35-45
my $branch = $builder->build({ source => 'Branch', });
Link Here
|
35 |
my $nb_of_categories = Koha::Patron::Categories->search->count; |
35 |
my $nb_of_categories = Koha::Patron::Categories->search->count; |
36 |
my $new_category_1 = Koha::Patron::Category->new({ |
36 |
my $new_category_1 = Koha::Patron::Category->new({ |
37 |
categorycode => 'mycatcodeX', |
37 |
categorycode => 'mycatcodeX', |
|
|
38 |
category_type => 'A', |
38 |
description => 'mycatdescX', |
39 |
description => 'mycatdescX', |
39 |
})->store; |
40 |
})->store; |
40 |
$new_category_1->add_branch_limitation( $branch->{branchcode} ); |
41 |
$new_category_1->add_branch_limitation( $branch->{branchcode} ); |
41 |
my $new_category_2 = Koha::Patron::Category->new({ |
42 |
my $new_category_2 = Koha::Patron::Category->new({ |
42 |
categorycode => 'mycatcodeY', |
43 |
categorycode => 'mycatcodeY', |
|
|
44 |
category_type => 'S', |
43 |
description => 'mycatdescY', |
45 |
description => 'mycatdescY', |
44 |
checkprevcheckout => undef, |
46 |
checkprevcheckout => undef, |
45 |
})->store; |
47 |
})->store; |
Lines 60-65
C4::Context->_new_userenv('my_new_userenv');
Link Here
|
60 |
C4::Context->set_userenv( 0, 0, 'usercnum', 'firstname', 'surname', $another_branch->{branchcode}, 'My wonderful library', '', '', '' ); |
62 |
C4::Context->set_userenv( 0, 0, 'usercnum', 'firstname', 'surname', $another_branch->{branchcode}, 'My wonderful library', '', '', '' ); |
61 |
my $new_category_3 = Koha::Patron::Category->new( |
63 |
my $new_category_3 = Koha::Patron::Category->new( |
62 |
{ categorycode => 'mycatcodeZ', |
64 |
{ categorycode => 'mycatcodeZ', |
|
|
65 |
category_type => 'A', |
63 |
description => 'mycatdescZ', |
66 |
description => 'mycatdescZ', |
64 |
} |
67 |
} |
65 |
)->store; |
68 |
)->store; |
Lines 71-76
is( scalar( grep { $_ eq $new_category_1->categorycode } @limited_category_codes
Link Here
|
71 |
is( scalar( grep { $_ eq $new_category_2->categorycode } @limited_category_codes ), 1, 'The second category is not limited' ); |
74 |
is( scalar( grep { $_ eq $new_category_2->categorycode } @limited_category_codes ), 1, 'The second category is not limited' ); |
72 |
is( scalar( grep { $_ eq $new_category_3->categorycode } @limited_category_codes ), 1, 'The third category is limited to my branch ' ); |
75 |
is( scalar( grep { $_ eq $new_category_3->categorycode } @limited_category_codes ), 1, 'The third category is limited to my branch ' ); |
73 |
|
76 |
|
|
|
77 |
my @limited_categories_for_A = Koha::Patron::Categories->search_limited({ category_type => 'A' }); |
78 |
my @limited_category_codes_for_A = map { $_->categorycode } @limited_categories_for_A; |
79 |
is( scalar( grep { $_ eq $new_category_2->categorycode } @limited_category_codes_for_A ), 0, 'The second category is not limited but has a category_type S' ); |
80 |
is( scalar( grep { $_ eq $new_category_3->categorycode } @limited_category_codes_for_A ), 1, 'The third category is limited to my branch and has a category_type A' ); |
81 |
|
74 |
$retrieved_category_1->delete; |
82 |
$retrieved_category_1->delete; |
75 |
is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'Delete should have deleted the patron category' ); |
83 |
is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'Delete should have deleted the patron category' ); |
76 |
|
84 |
|
77 |
- |
|
|