| Lines 17-23
          
      
      
        Link Here | 
        
          | 17 |  | 17 |  | 
        
          | 18 | use Modern::Perl; | 18 | use Modern::Perl; | 
        
          | 19 |  | 19 |  | 
          
            
              | 20 | use Test::More tests => 98; | 20 | use Test::More tests => 99; | 
        
          | 21 |  | 21 |  | 
        
          | 22 | use DateTime; | 22 | use DateTime; | 
        
          | 23 |  | 23 |  | 
  
    | Lines 74-79
          my $borrower = {
      
      
        Link Here | 
        
          | 74 |     branchcode => $library2->{branchcode} | 74 |     branchcode => $library2->{branchcode} | 
        
          | 75 | }; | 75 | }; | 
        
          | 76 |  | 76 |  | 
            
              |  |  | 77 | t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); | 
            
              | 78 |  | 
        
          | 77 | # No userenv, PickupLibrary | 79 | # No userenv, PickupLibrary | 
        
          | 78 | t::lib::Mocks::mock_preference('IndependentBranches', '0'); | 80 | t::lib::Mocks::mock_preference('IndependentBranches', '0'); | 
        
          | 79 | t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); | 81 | t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); | 
  
    | Lines 1639-1644
          subtest 'AddReturn + CumulativeRestrictionPeriods' => sub {
      
      
        Link Here | 
        
          | 1639 |     is( $debarments->[0]->{expiration}, $expected_expiration ); | 1641 |     is( $debarments->[0]->{expiration}, $expected_expiration ); | 
        
          | 1640 | }; | 1642 | }; | 
        
          | 1641 |  | 1643 |  | 
            
              |  |  | 1644 | subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { | 
            
              | 1645 |     plan tests => 2; | 
            
              | 1646 |  | 
            
              | 1647 |     my $library = $builder->build( { source => 'Branch' } ); | 
            
              | 1648 |     my $patron1 = $builder->build( | 
            
              | 1649 |         { | 
            
              | 1650 |             source => 'Borrower', | 
            
              | 1651 |             value  => { | 
            
              | 1652 |                 branchcode => $library->{branchcode}, | 
            
              | 1653 |             } | 
            
              | 1654 |         } | 
            
              | 1655 |     ); | 
            
              | 1656 |     my $patron2 = $builder->build( | 
            
              | 1657 |         { | 
            
              | 1658 |             source => 'Borrower', | 
            
              | 1659 |             value  => { | 
            
              | 1660 |                 branchcode => $library->{branchcode}, | 
            
              | 1661 |             } | 
            
              | 1662 |         } | 
            
              | 1663 |     ); | 
            
              | 1664 |  | 
            
              | 1665 |     C4::Context->_new_userenv('xxx'); | 
            
              | 1666 |     C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Random Library', '', '', ''); | 
            
              | 1667 |  | 
            
              | 1668 |     my $biblioitem = $builder->build( { source => 'Biblioitem' } ); | 
            
              | 1669 |     my $biblionumber = $biblioitem->{biblionumber}; | 
            
              | 1670 |     my $item = $builder->build( | 
            
              | 1671 |         {   source => 'Item', | 
            
              | 1672 |             value  => { | 
            
              | 1673 |                 homebranch    => $library->{branchcode}, | 
            
              | 1674 |                 holdingbranch => $library->{branchcode}, | 
            
              | 1675 |                 notforloan    => 0, | 
            
              | 1676 |                 itemlost      => 0, | 
            
              | 1677 |                 withdrawn     => 0, | 
            
              | 1678 |                 biblionumber  => $biblionumber, | 
            
              | 1679 |             } | 
            
              | 1680 |         } | 
            
              | 1681 |     ); | 
            
              | 1682 |  | 
            
              | 1683 |     my ( $error, $question, $alerts ); | 
            
              | 1684 |     my $issue = AddIssue( $patron1, $item->{barcode} ); | 
            
              | 1685 |  | 
            
              | 1686 |     t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); | 
            
              | 1687 |     ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); | 
            
              | 1688 |     is( $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER question flag should be set if AutoReturnCheckedOutItems is disabled and item is checked out to another' ); | 
            
              | 1689 |  | 
            
              | 1690 |     t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 1); | 
            
              | 1691 |     ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); | 
            
              | 1692 |     is( $alerts->{RETURNED_FROM_ANOTHER}->{patron}->borrowernumber, $patron1->{borrowernumber}, 'RETURNED_FROM_ANOTHER alert flag should be set if AutoReturnCheckedOutItems is enabled and item is checked out to another' ); | 
            
              | 1693 |  | 
            
              | 1694 |     t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); | 
            
              | 1695 | }; | 
            
              | 1696 |  | 
            
              | 1697 |  | 
        
          | 1642 | subtest 'AddReturn | is_overdue' => sub { | 1698 | subtest 'AddReturn | is_overdue' => sub { | 
        
          | 1643 |     plan tests => 5; | 1699 |     plan tests => 5; | 
        
          | 1644 |  | 1700 |  | 
            
              | 1645 | -  |  |  |