| Lines 19-25
          
      
      
        Link Here | 
        
          | 19 |  | 19 |  | 
        
          | 20 | use Modern::Perl; | 20 | use Modern::Perl; | 
        
          | 21 |  | 21 |  | 
          
            
              | 22 | use Test::More tests => 9; | 22 | use Test::More tests => 11; | 
        
          | 23 |  | 23 |  | 
        
          | 24 | use C4::Context; | 24 | use C4::Context; | 
        
          | 25 | use Koha::Database; | 25 | use Koha::Database; | 
  
    | 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 | })->store; | 46 | })->store; | 
        
          | 45 |  | 47 |  | 
  
    | Lines 55-60
          C4::Context->_new_userenv('my_new_userenv');
      
      
        Link Here | 
        
          | 55 | C4::Context->set_userenv( 0, 0, 'usercnum', 'firstname', 'surname', $another_branch->{branchcode}, 'My wonderful library', '', '', '' ); | 57 | C4::Context->set_userenv( 0, 0, 'usercnum', 'firstname', 'surname', $another_branch->{branchcode}, 'My wonderful library', '', '', '' ); | 
        
          | 56 | my $new_category_3 = Koha::Patron::Category->new( | 58 | my $new_category_3 = Koha::Patron::Category->new( | 
        
          | 57 |     {   categorycode => 'mycatcodeZ', | 59 |     {   categorycode => 'mycatcodeZ', | 
            
              |  |  | 60 |         category_type => 'A', | 
        
          | 58 |         description  => 'mycatdescZ', | 61 |         description  => 'mycatdescZ', | 
        
          | 59 |     } | 62 |     } | 
        
          | 60 | )->store; | 63 | )->store; | 
  
    | Lines 66-71
          is( scalar( grep { $_ eq $new_category_1->categorycode } @limited_category_codes
      
      
        Link Here | 
        
          | 66 | is( scalar( grep { $_ eq $new_category_2->categorycode } @limited_category_codes ), 1, 'The second category is not limited' ); | 69 | is( scalar( grep { $_ eq $new_category_2->categorycode } @limited_category_codes ), 1, 'The second category is not limited' ); | 
        
          | 67 | is( scalar( grep { $_ eq $new_category_3->categorycode } @limited_category_codes ), 1, 'The third category is limited to my branch ' ); | 70 | is( scalar( grep { $_ eq $new_category_3->categorycode } @limited_category_codes ), 1, 'The third category is limited to my branch ' ); | 
        
          | 68 |  | 71 |  | 
            
              |  |  | 72 | my @limited_categories_for_A = Koha::Patron::Categories->search_limited({ category_type => 'A' }); | 
            
              | 73 | my @limited_category_codes_for_A = map { $_->categorycode } @limited_categories_for_A; | 
            
              | 74 | 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' ); | 
            
              | 75 | 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' ); | 
            
              | 76 |  | 
        
          | 69 | $retrieved_category_1->delete; | 77 | $retrieved_category_1->delete; | 
        
          | 70 | is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'Delete should have deleted the patron category' ); | 78 | is( Koha::Patron::Categories->search->count, $nb_of_categories + 2, 'Delete should have deleted the patron category' ); | 
        
          | 71 |  | 79 |  | 
            
              | 72 | -  |  |  |