| Lines 18-24
          
      
      
        Link Here | 
        
          | 18 | use Modern::Perl; | 18 | use Modern::Perl; | 
        
          | 19 | use utf8; | 19 | use utf8; | 
        
          | 20 |  | 20 |  | 
          
            
              | 21 | use Test::More tests => 125; | 21 | use Test::More tests => 126; | 
        
          | 22 | use Test::MockModule; | 22 | use Test::MockModule; | 
        
          | 23 |  | 23 |  | 
        
          | 24 | use Data::Dumper; | 24 | use Data::Dumper; | 
  
    | Lines 105-110
          my $borrower = {
      
      
        Link Here | 
        
          | 105 |     branchcode => $library2->{branchcode} | 105 |     branchcode => $library2->{branchcode} | 
        
          | 106 | }; | 106 | }; | 
        
          | 107 |  | 107 |  | 
            
              |  |  | 108 | t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); | 
            
              | 109 |  | 
        
          | 108 | # No userenv, PickupLibrary | 110 | # No userenv, PickupLibrary | 
        
          | 109 | t::lib::Mocks::mock_preference('IndependentBranches', '0'); | 111 | t::lib::Mocks::mock_preference('IndependentBranches', '0'); | 
        
          | 110 | t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); | 112 | t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary'); | 
  
    | Lines 1904-1909
          subtest 'AddReturn + suspension_chargeperiod' => sub {
      
      
        Link Here | 
        
          | 1904 |     ); | 1906 |     ); | 
        
          | 1905 | }; | 1907 | }; | 
        
          | 1906 |  | 1908 |  | 
            
              |  |  | 1909 | subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub { | 
            
              | 1910 |     plan tests => 2; | 
            
              | 1911 |  | 
            
              | 1912 |     my $library = $builder->build( { source => 'Branch' } ); | 
            
              | 1913 |     my $patron1 = $builder->build_object( | 
            
              | 1914 |         { | 
            
              | 1915 |             class => 'Koha::Patrons', | 
            
              | 1916 |             value  => { | 
            
              | 1917 |                 branchcode => $library->{branchcode}, | 
            
              | 1918 |                 firstname => "Happy", | 
            
              | 1919 |                 surname => "Gilmore", | 
            
              | 1920 |             } | 
            
              | 1921 |         } | 
            
              | 1922 |     ); | 
            
              | 1923 |     my $patron2 = $builder->build_object( | 
            
              | 1924 |         { | 
            
              | 1925 |             class => 'Koha::Patrons', | 
            
              | 1926 |             value  => { | 
            
              | 1927 |                 branchcode => $library->{branchcode}, | 
            
              | 1928 |                 firstname => "Billy", | 
            
              | 1929 |                 surname => "Madison", | 
            
              | 1930 |             } | 
            
              | 1931 |         } | 
            
              | 1932 |     ); | 
            
              | 1933 |  | 
            
              | 1934 |     C4::Context->_new_userenv('xxx'); | 
            
              | 1935 |     C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Random Library', '', '', ''); | 
            
              | 1936 |  | 
            
              | 1937 |     my $biblioitem = $builder->build( { source => 'Biblioitem' } ); | 
            
              | 1938 |     my $biblionumber = $biblioitem->{biblionumber}; | 
            
              | 1939 |     my $item = $builder->build( | 
            
              | 1940 |         {   source => 'Item', | 
            
              | 1941 |             value  => { | 
            
              | 1942 |                 homebranch    => $library->{branchcode}, | 
            
              | 1943 |                 holdingbranch => $library->{branchcode}, | 
            
              | 1944 |                 notforloan    => 0, | 
            
              | 1945 |                 itemlost      => 0, | 
            
              | 1946 |                 withdrawn     => 0, | 
            
              | 1947 |                 biblionumber  => $biblionumber, | 
            
              | 1948 |             } | 
            
              | 1949 |         } | 
            
              | 1950 |     ); | 
            
              | 1951 |  | 
            
              | 1952 |     my ( $error, $question, $alerts ); | 
            
              | 1953 |     my $issue = AddIssue( $patron1->unblessed, $item->{barcode} ); | 
            
              | 1954 |  | 
            
              | 1955 |     t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); | 
            
              | 1956 |     ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); | 
            
              | 1957 |     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' ); | 
            
              | 1958 |  | 
            
              | 1959 |     t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 1); | 
            
              | 1960 |     ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} ); | 
            
              | 1961 |     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' ); | 
            
              | 1962 |  | 
            
              | 1963 |     t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0); | 
            
              | 1964 | }; | 
            
              | 1965 |  | 
            
              | 1966 |  | 
        
          | 1907 | subtest 'AddReturn | is_overdue' => sub { | 1967 | subtest 'AddReturn | is_overdue' => sub { | 
        
          | 1908 |     plan tests => 5; | 1968 |     plan tests => 5; | 
        
          | 1909 |  | 1969 |  | 
            
              | 1910 | -  |  |  |