| Lines 37-63
          t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 );
      
      
        Link Here | 
        
          | 37 |  | 37 |  | 
        
          | 38 | subtest 'list() tests' => sub { | 38 | subtest 'list() tests' => sub { | 
        
          | 39 |  | 39 |  | 
          
            
              | 40 |     plan tests => 7; | 40 |     plan tests => 15; | 
        
          | 41 |  | 41 |  | 
        
          | 42 |     $schema->storage->txn_begin; | 42 |     $schema->storage->txn_begin; | 
        
          | 43 |  | 43 |  | 
          
            
              | 44 |     # delete all patrons | 44 |     my $library = $builder->build_object( { class => 'Koha::Libraries' } ); | 
            
              | 45 |     Koha::Patrons->search->delete; |  |  | 
        
          | 46 |  | 45 |  | 
          
            
              | 47 |     # delete all categories | 46 |     my $category = $builder->build_object( | 
            
              | 48 |     Koha::Patron::Categories->search->delete; |  |  | 
            
              | 49 |  | 
            
              | 50 |     $builder->build_object( | 
        
          | 51 |         { | 47 |         { | 
        
          | 52 |             class => 'Koha::Patron::Categories', | 48 |             class => 'Koha::Patron::Categories', | 
        
          | 53 |             value => { categorycode => 'TEST', description => 'Test' } | 49 |             value => { categorycode => 'TEST', description => 'Test' } | 
        
          | 54 |         } | 50 |         } | 
        
          | 55 |     ); | 51 |     ); | 
        
          | 56 |  | 52 |  | 
            
              |  |  | 53 |     $category->add_library_limit( $library->branchcode ); | 
            
              | 54 |  | 
        
          | 57 |     my $librarian = $builder->build_object( | 55 |     my $librarian = $builder->build_object( | 
        
          | 58 |         { | 56 |         { | 
        
          | 59 |             class => 'Koha::Patrons', | 57 |             class => 'Koha::Patrons', | 
          
            
              | 60 |             value => { flags => 2**3, categorycode => 'TEST' }    # parameters flag = 3 | 58 |             value => { flags => 2**3, categorycode => 'TEST', branchcode => $library->branchcode } # parameters flag = 3 | 
        
          | 61 |         } | 59 |         } | 
        
          | 62 |     ); | 60 |     ); | 
        
          | 63 |  | 61 |  | 
  
    | Lines 67-74
          subtest 'list() tests' => sub {
      
      
        Link Here | 
        
          | 67 |  | 65 |  | 
        
          | 68 |     $t->get_ok("//$userid:$password@/api/v1/patron_categories")->status_is(200); | 66 |     $t->get_ok("//$userid:$password@/api/v1/patron_categories")->status_is(200); | 
        
          | 69 |  | 67 |  | 
          
            
              | 70 |     $t->get_ok("//$userid:$password@/api/v1/patron_categories")->status_is(200)->json_has('/0/name') | 68 |     $t->get_ok("//$userid:$password@/api/v1/patron_categories?q={\"me.categorycode\":\"TEST\"}")->status_is(200) | 
            
              | 71 |         ->json_is( '/0/name' => 'Test' )->json_hasnt('/1'); | 69 |         ->json_has('/0/name')->json_is( '/0/name' => 'Test' )->json_hasnt('/1'); | 
            
              |  |  | 70 |  | 
            
              | 71 |     # Off limits search | 
            
              | 72 |  | 
            
              | 73 |     my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); | 
            
              | 74 |  | 
            
              | 75 |     my $off_limits_category = $builder->build_object( | 
            
              | 76 |         { | 
            
              | 77 |             class => 'Koha::Patron::Categories', | 
            
              | 78 |             value => { categorycode => 'CANT', description => 'Cant' } | 
            
              | 79 |         } | 
            
              | 80 |     ); | 
            
              | 81 |  | 
            
              | 82 |     my $off_limits_librarian = $builder->build_object( | 
            
              | 83 |         { | 
            
              | 84 |             class => 'Koha::Patrons', | 
            
              | 85 |             value => | 
            
              | 86 |                 { flags => 2**3, categorycode => 'CANT', branchcode => $library_2->branchcode }    # parameters flag = 3 | 
            
              | 87 |         } | 
            
              | 88 |     ); | 
            
              | 89 |     my $off_limits_password = 'thePassword123'; | 
            
              | 90 |     $off_limits_librarian->set_password( { password => $password, skip_validation => 1 } ); | 
            
              | 91 |     my $off_limits_userid = $off_limits_librarian->userid; | 
            
              | 92 |  | 
            
              | 93 |     $t->get_ok("//$off_limits_userid:$off_limits_password@/api/v1/patron_categories?q={\"me.categorycode\":\"TEST\"}") | 
            
              | 94 |         ->status_is(200)->json_hasnt('/0'); | 
            
              | 95 |  | 
            
              | 96 |     # Off limits librarian category has changed to one within limits | 
            
              | 97 |  | 
            
              | 98 |     $off_limits_librarian->branchcode( $library->branchcode )->store; | 
            
              | 99 |  | 
            
              | 100 |     $t->get_ok("//$off_limits_userid:$off_limits_password@/api/v1/patron_categories?q={\"me.categorycode\":\"TEST\"}") | 
            
              | 101 |         ->status_is(200)->json_has('/0/name')->json_is( '/0/name' => 'Test' )->json_hasnt('/1'); | 
        
          | 72 |  | 102 |  | 
        
          | 73 |     $schema->storage->txn_rollback; | 103 |     $schema->storage->txn_rollback; | 
        
          | 74 |  | 104 |  | 
            
              | 75 | -  |  |  |