| Lines 20-26
          
      
      
        Link Here | 
        
          | 20 | use Modern::Perl; | 20 | use Modern::Perl; | 
        
          | 21 | use utf8; | 21 | use utf8; | 
        
          | 22 |  | 22 |  | 
          
            
              | 23 | use Test::More tests => 38; | 23 | use Test::More tests => 39; | 
        
          | 24 | use Test::Exception; | 24 | use Test::Exception; | 
        
          | 25 | use Test::MockModule; | 25 | use Test::MockModule; | 
        
          | 26 | use Test::Warn; | 26 | use Test::Warn; | 
  
    | Lines 45-50
          use t::lib::Dates;
      
      
        Link Here | 
        
          | 45 | my $schema  = Koha::Database->new->schema; | 45 | my $schema  = Koha::Database->new->schema; | 
        
          | 46 | my $builder = t::lib::TestBuilder->new; | 46 | my $builder = t::lib::TestBuilder->new; | 
        
          | 47 |  | 47 |  | 
            
              |  |  | 48 | subtest '_status' => sub { | 
            
              | 49 |     plan tests => 12; | 
            
              | 50 |  | 
            
              | 51 |     $schema->storage->txn_begin; | 
            
              | 52 |  | 
            
              | 53 |     my $item    = $builder->build_sample_item(); | 
            
              | 54 |     my $library = $builder->build_object( { class => 'Koha::Libraries' } ); | 
            
              | 55 |     t::lib::Mocks::mock_userenv( { branchcode => $library->branchcode } ); | 
            
              | 56 |  | 
            
              | 57 |     t::lib::Mocks::mock_preference( 'UseRecalls', 1 ); | 
            
              | 58 |  | 
            
              | 59 |     my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); | 
            
              | 60 |  | 
            
              | 61 |     my @test_cases = ( | 
            
              | 62 |         { | 
            
              | 63 |             setup => sub { | 
            
              | 64 |                 my $onloan_item = $builder->build_sample_item(); | 
            
              | 65 |                 AddIssue( $patron, $onloan_item->barcode, dt_from_string ); | 
            
              | 66 |                 return $onloan_item; | 
            
              | 67 |             }, | 
            
              | 68 |             expected_status => 'checked_out', | 
            
              | 69 |             description     => 'Checked out status correctly returned', | 
            
              | 70 |         }, | 
            
              | 71 |         { | 
            
              | 72 |             setup => sub { | 
            
              | 73 |                 my $onsite_item = $builder->build_sample_item(); | 
            
              | 74 |                 AddIssue( | 
            
              | 75 |                     $patron, $onsite_item->barcode, dt_from_string, undef, undef, undef, | 
            
              | 76 |                     { onsite_checkout => 1 } | 
            
              | 77 |                 ); | 
            
              | 78 |                 return $onsite_item; | 
            
              | 79 |             }, | 
            
              | 80 |             expected_status => 'local_use', | 
            
              | 81 |             description     => 'Local use status correctly returned', | 
            
              | 82 |         }, | 
            
              | 83 |         { | 
            
              | 84 |             setup => sub { | 
            
              | 85 |                 return $item; | 
            
              | 86 |             }, | 
            
              | 87 |             expected_status => 'available', | 
            
              | 88 |             description     => 'Available status correctly returned', | 
            
              | 89 |         }, | 
            
              | 90 |         { | 
            
              | 91 |             setup => sub { | 
            
              | 92 |                 $item->itemlost(1)->store(); | 
            
              | 93 |                 return $item; | 
            
              | 94 |             }, | 
            
              | 95 |             expected_status => 'lost', | 
            
              | 96 |             description     => 'Lost status correctly returned', | 
            
              | 97 |         }, | 
            
              | 98 |         { | 
            
              | 99 |             setup => sub { | 
            
              | 100 |                 $item->withdrawn(1)->store(); | 
            
              | 101 |                 return $item; | 
            
              | 102 |             }, | 
            
              | 103 |             expected_status => qr/lost,withdrawn/, | 
            
              | 104 |             description     => 'Lost and withdrawn status correctly returned', | 
            
              | 105 |         }, | 
            
              | 106 |         { | 
            
              | 107 |             setup => sub { | 
            
              | 108 |                 $item->damaged(1)->store(); | 
            
              | 109 |                 return $item; | 
            
              | 110 |             }, | 
            
              | 111 |             expected_status => qr/lost,withdrawn,damaged/, | 
            
              | 112 |             description     => 'Lost, withdrawn, and damaged status correctly returned', | 
            
              | 113 |         }, | 
            
              | 114 |         { | 
            
              | 115 |             setup => sub { | 
            
              | 116 |                 $item->notforloan(1)->store(); | 
            
              | 117 |                 return $item; | 
            
              | 118 |             }, | 
            
              | 119 |             expected_status => 'not_for_loan', | 
            
              | 120 |             description     => 'Positive not_for_loan status correctly returned', | 
            
              | 121 |         }, | 
            
              | 122 |         { | 
            
              | 123 |             setup => sub { | 
            
              | 124 |                 $item->notforloan(-1)->store(); | 
            
              | 125 |                 return $item; | 
            
              | 126 |             }, | 
            
              | 127 |             expected_status => 'not_for_loan', | 
            
              | 128 |             description     => 'Negative not_for_loan status correctly returned', | 
            
              | 129 |         }, | 
            
              | 130 |         { | 
            
              | 131 |             setup => sub { | 
            
              | 132 |                 my $itemtype = $builder->build_object( { class => "Koha::ItemTypes", value => { notforloan => 1 } } ); | 
            
              | 133 |                 my $notforloan_item = $builder->build_sample_item( { itype => $itemtype->itemtype, } ); | 
            
              | 134 |                 return $notforloan_item; | 
            
              | 135 |             }, | 
            
              | 136 |             expected_status => 'not_for_loan', | 
            
              | 137 |             description     => 'Item type not_for_loan status correctly returned', | 
            
              | 138 |         }, | 
            
              | 139 |         { | 
            
              | 140 |             setup => sub { | 
            
              | 141 |                 my $onhold_item = $builder->build_sample_item(); | 
            
              | 142 |                 C4::Reserves::AddReserve( | 
            
              | 143 |                     { | 
            
              | 144 |                         branchcode     => $library->branchcode, | 
            
              | 145 |                         borrowernumber => $patron->borrowernumber, | 
            
              | 146 |                         biblionumber   => $onhold_item->biblionumber, | 
            
              | 147 |                         itemnumber     => $onhold_item->itemnumber, | 
            
              | 148 |                     } | 
            
              | 149 |                 ); | 
            
              | 150 |                 return $onhold_item; | 
            
              | 151 |             }, | 
            
              | 152 |             expected_status => 'on_hold', | 
            
              | 153 |             description     => 'On hold status correctly returned', | 
            
              | 154 |         }, | 
            
              | 155 |         { | 
            
              | 156 |             setup => sub { | 
            
              | 157 |                 my $recalled_item = $builder->build_sample_item(); | 
            
              | 158 |                 AddIssue( $patron, $recalled_item->barcode, dt_from_string ); | 
            
              | 159 |                 Koha::Recalls->add_recall( | 
            
              | 160 |                     { biblio => $recalled_item->biblio, item => $recalled_item, patron => $patron } ); | 
            
              | 161 |                 return $recalled_item; | 
            
              | 162 |             }, | 
            
              | 163 |             expected_status => 'recalled', | 
            
              | 164 |             description     => 'Recalled status correctly returned', | 
            
              | 165 |         }, | 
            
              | 166 |         { | 
            
              | 167 |             setup => sub { | 
            
              | 168 |                 $item->restricted(1)->store(); | 
            
              | 169 |                 return $item; | 
            
              | 170 |             }, | 
            
              | 171 |             expected_status => 'restricted', | 
            
              | 172 |             description     => 'Restricted status correctly returned', | 
            
              | 173 |         }, | 
            
              | 174 |     ); | 
            
              | 175 |  | 
            
              | 176 |     foreach my $test_case (@test_cases) { | 
            
              | 177 |         my $item = $test_case->{setup}->(); | 
            
              | 178 |         ok( $item->_status() =~ /$test_case->{expected_status}/, $test_case->{description} ); | 
            
              | 179 |     } | 
            
              | 180 |  | 
            
              | 181 |     t::lib::Mocks::mock_preference( 'UseRecalls', 0 ); | 
            
              | 182 |  | 
            
              | 183 |     $schema->storage->txn_rollback; | 
            
              | 184 | }; | 
            
              | 185 |  | 
        
          | 48 | subtest 'z3950_status' => sub { | 186 | subtest 'z3950_status' => sub { | 
        
          | 49 |     plan tests => 9; | 187 |     plan tests => 9; | 
        
          | 50 |  | 188 |  | 
            
              | 51 | -  |  |  |