https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=8127

--- Comment #4 from Baptiste Wojtkowski (bwoj) 
<[email protected]> ---
This is a script that might help running the upcoming test plan:



  use C4::Circulation qw( AddIssue AddReturn );
  use Koha::Items;
  use Koha::Patrons;
  use t::lib::Mocks;
  use Koha::DateUtils qw(dt_from_string);

S>my $koha_user = Koha::Patrons->find(51);
  t::lib::Mocks::mock_userenv({patron => $koha_user});

  my $henry = Koha::Patrons->find(19);
  my $edna = Koha::Patrons->find(5);
  my $book1 = Koha::Items->find({ itemnumber => 1 });
  my $book2 = Koha::Items->find({ itemnumber => 2 });
  my $book3 = Koha::Items->find({ itemnumber => 12 });
  my $book4 = Koha::Items->find({ itemnumber => 19 });
  my $book5 = Koha::Items->find({ itemnumber => 21 });
  my $musics = Koha::Items->search({ itype => 'MU' });
  my $music1 = $musics->next;

  my $nb_days;

  for( my $i = 10; $i<100; $i++){
      $nb_days = $i;
      my $item;
      my $patron;
      my $branch;
      if ($i == 15){
          $item = $book3;
      } elsif ($i == 16){
          $item = $book4;
      } elsif ($i == 17){
          $item = $book5;
      } elsif ($i < 30){
          $item = $book1;
      }
      elsif ($i < 70){
          $item = $book2;
      }
      else {
          $item = $music1;
      };
      if ($i % 2 == 1){
          $patron = $edna;
      }
      else {
          $patron = $henry;
      }
    if ($i % 3 == 0){
          $branchcode = 'CPL';
      }
      elsif ($i % 3 == 1){
          $branchcode = 'MPL';
      }
      else {
          $branchcode = 'FFL';
      };
      $branch = t::lib::Mocks::mock_userenv({branchcode => $branchcode});

      my $due = dt_from_string->subtract(days =>
$nb_days)->set_hour(12)->set_minute(00)->set_second(00);
      AddIssue($patron, $item->barcode, $due);
      AddReturn($item->barcode, $branchcode);
      my $returned_date = dt_from_string->subtract(days =>
$nb_days)->set_hour(12)->set_minute(00)->set_second(00);
      my $lastIssue = Koha::Old::Checkouts->filter_by_last_update({
              younger_than => 0,
              timestamp_column_name => 'returndate',
          })->single;
      $lastIssue->set({ returndate => $returned_date })->store();
      $lastIssue->set({ issuedate => $returned_date })->store();
  }

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to