| 
      
            Lines 5-18
          
      
      
        Link Here
      
     | 
  
        
          | 5 | 
          # Larger modifications by Jonathan Druart and Marcel de Rooy  | 
          5 | 
          # Larger modifications by Jonathan Druart and Marcel de Rooy  | 
        
        
          | 6 | 
           | 
          6 | 
           | 
        
        
          | 7 | 
          use Modern::Perl;  | 
          7 | 
          use Modern::Perl;  | 
        
          
            
              | 8 | 
              use Test::More tests => 81;  | 
              8 | 
              use Test::More tests => 71;  | 
            
        
          | 9 | 
          use MARC::Record;  | 
          9 | 
          use MARC::Record;  | 
        
        
          | 10 | 
           | 
          10 | 
           | 
        
        
          | 11 | 
          use C4::Biblio qw( AddBiblio DelBiblio );  | 
          11 | 
          use C4::Biblio qw( AddBiblio DelBiblio );  | 
        
        
          | 12 | 
          use C4::Context;  | 
          12 | 
          use C4::Context;  | 
        
        
          | 13 | 
           | 
          13 | 
           | 
        
          
            
              | 14 | 
              # Getting some borrowers from database.  | 
              14 | 
               | 
            
        
          | 15 | 
          my $dbh = C4::Context->dbh;  | 
          15 | 
          my $dbh = C4::Context->dbh;  | 
        
            
               | 
               | 
              16 | 
              $dbh->{RaiseError} = 1; | 
            
            
              | 17 | 
              $dbh->{AutoCommit} = 0; | 
            
            
              | 18 | 
               | 
            
            
              | 19 | 
              # Getting some borrowers from database.  | 
            
        
          | 16 | 
          my $query = q{SELECT borrowernumber FROM borrowers LIMIT 10}; | 
          20 | 
          my $query = q{SELECT borrowernumber FROM borrowers LIMIT 10}; | 
        
        
          | 17 | 
          my $borr_ref=$dbh->selectall_arrayref($query);  | 
          21 | 
          my $borr_ref=$dbh->selectall_arrayref($query);  | 
        
        
          | 18 | 
          if(@$borr_ref==0) { #no borrowers? should not occur of course | 
          22 | 
          if(@$borr_ref==0) { #no borrowers? should not occur of course | 
        
  
    | 
      
            Lines 46-52
          use_ok('C4::VirtualShelves');
      
      
        Link Here
      
     | 
  
        
          | 46 | 
           | 
          50 | 
           | 
        
        
          | 47 | 
          # creating shelves (could be <10 when names are not unique)  | 
          51 | 
          # creating shelves (could be <10 when names are not unique)  | 
        
        
          | 48 | 
          my @shelves;  | 
          52 | 
          my @shelves;  | 
        
          
            
              | 49 | 
              for(my $i=0; $i<10;$i++) { | 
              53 | 
              for my $i(0..9){ | 
            
        
          | 50 | 
              my $name= randomname();  | 
          54 | 
              my $name= randomname();  | 
        
        
          | 51 | 
              my $catg= int(rand(2))+1;  | 
          55 | 
              my $catg= int(rand(2))+1;  | 
        
        
          | 52 | 
              my $ShelfNumber= AddShelf(  | 
          56 | 
              my $ShelfNumber= AddShelf(  | 
        
  
    | 
      
            Lines 73-79
          for(my $i=0; $i<10;$i++) {
      
      
        Link Here
      
     | 
  
        
          | 73 | 
          }  | 
          77 | 
          }  | 
        
        
          | 74 | 
           | 
          78 | 
           | 
        
        
          | 75 | 
          # try to create shelves with duplicate names  | 
          79 | 
          # try to create shelves with duplicate names  | 
        
          
            
              | 76 | 
              for(my $i=0;$i<10;$i++){ | 
              80 | 
              for my $i(0..9){ | 
            
        
          | 77 | 
              if($shelves[$i]->{number}<0) { | 
          81 | 
              if($shelves[$i]->{number}<0) { | 
        
        
          | 78 | 
                  ok(1, 'skip duplicate test for earlier name clash');  | 
          82 | 
                  ok(1, 'skip duplicate test for earlier name clash');  | 
        
        
          | 79 | 
                  next;  | 
          83 | 
                  next;  | 
        
  
    | 
      
            Lines 108-114
          for(my $i=0;$i<10;$i++){
      
      
        Link Here
      
     | 
  
        
          | 108 | 
          # usage : $biblist = GetShelfContents($shelfnumber);  | 
          112 | 
          # usage : $biblist = GetShelfContents($shelfnumber);  | 
        
        
          | 109 | 
           | 
          113 | 
           | 
        
        
          | 110 | 
          my %used = ();  | 
          114 | 
          my %used = ();  | 
        
          
            
              | 111 | 
              for(my $i=0; $i<10;$i++){ | 
              115 | 
              for my $i(0..9){ | 
            
        
          | 112 | 
              my $bib = $biblionumbers[int(rand(9))];  | 
          116 | 
              my $bib = $biblionumbers[int(rand(9))];  | 
        
        
          | 113 | 
              my $shelfnumber = $shelves[int(rand(9))]->{number}; | 
          117 | 
              my $shelfnumber = $shelves[int(rand(9))]->{number}; | 
        
        
          | 114 | 
              if($shelfnumber<0) { | 
          118 | 
              if($shelfnumber<0) { | 
        
  
    | 
      
            Lines 145-151
          for(my $i=0; $i<10;$i++){
      
      
        Link Here
      
     | 
  
        
          | 145 | 
          # usage : ModShelf($shelfnumber, $shelfname, $owner, $category )  | 
          149 | 
          # usage : ModShelf($shelfnumber, $shelfname, $owner, $category )  | 
        
        
          | 146 | 
          # usage : (shelfnumber,shelfname,owner,category) = GetShelf($shelfnumber);  | 
          150 | 
          # usage : (shelfnumber,shelfname,owner,category) = GetShelf($shelfnumber);  | 
        
        
          | 147 | 
           | 
          151 | 
           | 
        
          
            
              | 148 | 
              for(my $i=0; $i<10;$i++){ | 
              152 | 
              for my $i(0..9){ | 
            
        
          | 149 | 
              my $rand = int(rand(9));  | 
          153 | 
              my $rand = int(rand(9));  | 
        
        
          | 150 | 
              my $numA = $shelves[$rand]->{number}; | 
          154 | 
              my $numA = $shelves[$rand]->{number}; | 
        
        
          | 151 | 
              if($numA<0) { | 
          155 | 
              if($numA<0) { | 
        
  
    | 
      
            Lines 173-195
          for(my $i=0; $i<10;$i++){
      
      
        Link Here
      
     | 
  
        
          | 173 | 
              }  | 
          177 | 
              }  | 
        
        
          | 174 | 
          }  | 
          178 | 
          }  | 
        
        
          | 175 | 
           | 
          179 | 
           | 
        
            
              | 176 | 
              #-----------------------TEST DelShelf & DelFromShelf functions------------------------#  | 
               | 
               | 
            
            
              | 177 | 
              # usage : ($status) = &DelShelf($shelfnumber);  | 
            
            
              | 178 | 
               | 
            
            
              | 179 | 
              for(my $i=0; $i<10;$i++){ | 
            
            
              | 180 | 
                  my $shelfnumber = $shelves[$i]->{number}; | 
            
            
              | 181 | 
                  if($shelfnumber<0) { | 
            
            
              | 182 | 
                      ok(1, 'Skip DelShelf for shelf -1');  | 
            
            
              | 183 | 
                      next;  | 
            
            
              | 184 | 
                  }  | 
            
            
              | 185 | 
                  my $status = DelShelf($shelfnumber);  | 
            
            
              | 186 | 
                  ok(1 == $status, "deleted shelf $shelfnumber and its contents");  | 
            
            
              | 187 | 
              }  | 
            
            
              | 188 | 
               | 
            
            
              | 189 | 
              #----------------------- CLEANUP ----------------------------------------------#  | 
            
            
              | 190 | 
               | 
            
            
              | 191 | 
              DelBiblio($_) for @biblionumbers;  | 
            
            
              | 192 | 
               | 
            
        
          | 193 | 
          #----------------------- SOME SUBS --------------------------------------------#  | 
          180 | 
          #----------------------- SOME SUBS --------------------------------------------#  | 
        
        
          | 194 | 
           | 
          181 | 
           | 
        
        
          | 195 | 
          sub randomname { | 
          182 | 
          sub randomname { | 
        
  
    | 
      
            Lines 199-201
          sub randomname {
      
      
        Link Here
      
     | 
  
        
          | 199 | 
              }  | 
          186 | 
              }  | 
        
        
          | 200 | 
              return $rv;  | 
          187 | 
              return $rv;  | 
        
        
          | 201 | 
          }  | 
          188 | 
          }  | 
        
          
            
              | 202 | 
              -   | 
              189 | 
               | 
            
            
               | 
               | 
              190 | 
              $dbh->rollback;  |