Lines 21-27
use Modern::Perl;
Link Here
|
21 |
use C4::Context; |
21 |
use C4::Context; |
22 |
use Data::Dumper; |
22 |
use Data::Dumper; |
23 |
|
23 |
|
24 |
use Test::More tests => 26; |
24 |
use Test::More tests => 24; |
25 |
|
25 |
|
26 |
use C4::Branch; |
26 |
use C4::Branch; |
27 |
use Koha::Libraries; |
27 |
use Koha::Libraries; |
Lines 43-49
can_ok(
Link Here
|
43 |
ModBranch |
43 |
ModBranch |
44 |
GetBranchInfo |
44 |
GetBranchInfo |
45 |
GetCategoryTypes |
45 |
GetCategoryTypes |
46 |
GetBranchCategories |
|
|
47 |
GetBranchesInCategory |
46 |
GetBranchesInCategory |
48 |
ModBranchCategoryInfo |
47 |
ModBranchCategoryInfo |
49 |
mybranch |
48 |
mybranch |
Lines 165-172
$b1->{issuing} = undef;
Link Here
|
165 |
is_deeply( $branchdetail, $b1 , "GetBranchDetail gives the details of BRA"); |
164 |
is_deeply( $branchdetail, $b1 , "GetBranchDetail gives the details of BRA"); |
166 |
|
165 |
|
167 |
#Test categories |
166 |
#Test categories |
168 |
my $categories = GetBranchCategories(); |
167 |
my $count_cat = Koha::LibraryCategories->search->count; |
169 |
my $count_cat = scalar( @$categories ); |
|
|
170 |
|
168 |
|
171 |
my $cat1 = { |
169 |
my $cat1 = { |
172 |
add => 1, |
170 |
add => 1, |
Lines 201-218
ModBranchCategoryInfo({
Link Here
|
201 |
ModBranchCategoryInfo($cat1); |
199 |
ModBranchCategoryInfo($cat1); |
202 |
ModBranchCategoryInfo($cat2); |
200 |
ModBranchCategoryInfo($cat2); |
203 |
|
201 |
|
204 |
$categories = GetBranchCategories(); |
202 |
my $categories = Koha::LibraryCategories->search; |
205 |
is( scalar( @$categories ), $count_cat + 3, "Two categories added" ); |
203 |
is( $categories->count, $count_cat + 3, "Two categories added" ); |
206 |
delete $cat1->{add}; |
204 |
delete $cat1->{add}; |
207 |
delete $cat2->{add}; |
205 |
delete $cat2->{add}; |
208 |
delete $new_category{add}; |
206 |
delete $new_category{add}; |
209 |
is_deeply($categories, [ $cat1,$cat2,\%new_category ], 'retrieve all expected library categories (bug 10515)'); |
|
|
210 |
|
207 |
|
211 |
my $del = Koha::LibraryCategories->find( $cat2->{categorycode} )->delete; |
208 |
my $del = Koha::LibraryCategories->find( $cat2->{categorycode} )->delete; |
212 |
is( $del, 1, 'One row affected' ); |
209 |
is( $del, 1, 'One row affected' ); |
213 |
|
210 |
|
214 |
$categories = GetBranchCategories(); |
211 |
is( Koha::LibraryCategories->search->count, $count_cat + 2, "Category CAT 2 deleted" ); |
215 |
is( scalar( @$categories ), $count_cat + 2, "Category CAT2 deleted" ); |
|
|
216 |
|
212 |
|
217 |
$b2->{CAT1} = 1; |
213 |
$b2->{CAT1} = 1; |
218 |
ModBranch($b2); |
214 |
ModBranch($b2); |
Lines 232-239
$b2->{categories} = \@cat;
Link Here
|
232 |
is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1' ); |
228 |
is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1' ); |
233 |
|
229 |
|
234 |
ModBranchCategoryInfo({add => 1,%$cat2}); |
230 |
ModBranchCategoryInfo({add => 1,%$cat2}); |
235 |
$categories = GetBranchCategories(); |
231 |
is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two catgories added" ); |
236 |
is( scalar( @$categories ), $count_cat + 3, "Two categories added" ); |
|
|
237 |
$b2 = { |
232 |
$b2 = { |
238 |
branchcode => 'BRB', |
233 |
branchcode => 'BRB', |
239 |
branchname => 'BranchB', |
234 |
branchname => 'BranchB', |
Lines 302-310
is_deeply( $brCat1, \@b, 'CAT1 has branch BRB and BRC' );
Link Here
|
302 |
my @category_types = GetCategoryTypes(); |
297 |
my @category_types = GetCategoryTypes(); |
303 |
is_deeply(\@category_types, [ 'searchdomain', 'properties' ], 'received expected library category types'); |
298 |
is_deeply(\@category_types, [ 'searchdomain', 'properties' ], 'received expected library category types'); |
304 |
|
299 |
|
305 |
$categories = GetBranchCategories(undef, undef, 'LIBCATCODE'); |
|
|
306 |
is_deeply($categories, [ {%$cat1}, {%$cat2},{ %new_category, selected => 1 } ], 'retrieve expected, eselected library category (bug 10515)'); |
307 |
|
308 |
#TODO later: test mybranchine and onlymine |
300 |
#TODO later: test mybranchine and onlymine |
309 |
# Actually we cannot mock C4::Context->userenv in unit tests |
301 |
# Actually we cannot mock C4::Context->userenv in unit tests |
310 |
|
302 |
|
311 |
- |
|
|