| 
      
            Lines 6-19
          
      
      
        Link Here
      
     | 
  
        
          | 6 | 
          #  | 
          6 | 
          #  | 
        
        
          | 7 | 
           | 
          7 | 
           | 
        
        
          | 8 | 
          use Modern::Perl;  | 
          8 | 
          use Modern::Perl;  | 
        
          
            
              | 9 | 
              use Test::More tests => 82;  | 
              9 | 
              use Test::More tests => 72;  | 
            
        
          | 10 | 
          use MARC::Record;  | 
          10 | 
          use MARC::Record;  | 
        
        
          | 11 | 
           | 
          11 | 
           | 
        
        
          | 12 | 
          use C4::Biblio qw( AddBiblio DelBiblio );  | 
          12 | 
          use C4::Biblio qw( AddBiblio DelBiblio );  | 
        
        
          | 13 | 
          use C4::Context;  | 
          13 | 
          use C4::Context;  | 
        
        
          | 14 | 
           | 
          14 | 
           | 
        
          
            
              | 15 | 
              # Getting some borrowers from database.  | 
              15 | 
              # Start transaction  | 
            
        
          | 16 | 
          my $dbh = C4::Context->dbh;  | 
          16 | 
          my $dbh = C4::Context->dbh;  | 
        
            
               | 
               | 
              17 | 
              $dbh->{RaiseError} = 1; | 
            
            
              | 18 | 
              $dbh->{AutoCommit} = 0; | 
            
            
              | 19 | 
               | 
            
            
              | 20 | 
              # Getting some borrowers from database.  | 
            
        
          | 17 | 
          my $query = q{ | 
          21 | 
          my $query = q{ | 
        
        
          | 18 | 
              SELECT borrowernumber  | 
          22 | 
              SELECT borrowernumber  | 
        
        
          | 19 | 
              FROM   borrowers  | 
          23 | 
              FROM   borrowers  | 
        
  
    | 
      
            Lines 34-40
          foreach(0..9) {
      
      
        Link Here
      
     | 
  
        
          | 34 | 
              push @biblionumbers, $biblionumber;  | 
          38 | 
              push @biblionumbers, $biblionumber;  | 
        
        
          | 35 | 
          }  | 
          39 | 
          }  | 
        
        
          | 36 | 
           | 
          40 | 
           | 
        
            
              | 37 | 
              # FIXME Why are you deleting my shelves? See bug 10386.  | 
               | 
               | 
            
        
          | 38 | 
          my $delete_virtualshelf = q{ | 
          41 | 
          my $delete_virtualshelf = q{ | 
        
        
          | 39 | 
              DELETE FROM  virtualshelves WHERE 1  | 
          42 | 
              DELETE FROM  virtualshelves WHERE 1  | 
        
        
          | 40 | 
          };  | 
          43 | 
          };  | 
        
  
    | 
      
            Lines 42-51
          my $delete_virtualshelfcontent = q{
      
      
        Link Here
      
     | 
  
        
          | 42 | 
              DELETE  FROM  virtualshelfcontents WHERE 1  | 
          45 | 
              DELETE  FROM  virtualshelfcontents WHERE 1  | 
        
        
          | 43 | 
          };  | 
          46 | 
          };  | 
        
        
          | 44 | 
           | 
          47 | 
           | 
        
          
            
              | 45 | 
              $sth = $dbh->prepare($delete_virtualshelf);  | 
              48 | 
              $dbh->do($delete_virtualshelf);  | 
            
            
              | 46 | 
              $sth->execute;  | 
              49 | 
              $dbh->do($delete_virtualshelfcontent);  | 
            
            
              | 47 | 
              $sth = $dbh->prepare($delete_virtualshelfcontent);  | 
               | 
               | 
            
            
              | 48 | 
              $sth->execute;  | 
            
        
          | 49 | 
          # ---  | 
          50 | 
          # ---  | 
        
        
          | 50 | 
           | 
          51 | 
           | 
        
        
          | 51 | 
          #----------------------------------------------------------------------#  | 
          52 | 
          #----------------------------------------------------------------------#  | 
        
  
    | 
      
            Lines 61-67
          use_ok('C4::VirtualShelves');
      
      
        Link Here
      
     | 
  
        
          | 61 | 
           | 
          62 | 
           | 
        
        
          | 62 | 
          # creating 10 good shelves.  | 
          63 | 
          # creating 10 good shelves.  | 
        
        
          | 63 | 
          my @shelves;  | 
          64 | 
          my @shelves;  | 
        
          
            
              | 64 | 
              for(my $i=0; $i<10;$i++){ | 
              65 | 
              for my $i(0..9){ | 
            
        
          | 65 | 
               my $ShelfNumber = AddShelf(  | 
          66 | 
               my $ShelfNumber = AddShelf(  | 
        
        
          | 66 | 
              {shelfname=>"Shelf_".$i, category=>int(rand(2))+1 }, $borrowers[$i] ); | 
          67 | 
              {shelfname=>"Shelf_".$i, category=>int(rand(2))+1 }, $borrowers[$i] ); | 
        
        
          | 67 | 
               die "test Not ok, remove some shelves before" if ($ShelfNumber == -1);  | 
          68 | 
               die "test Not ok, remove some shelves before" if ($ShelfNumber == -1);  | 
        
  
    | 
      
            Lines 72-78
          for(my $i=0; $i<10;$i++){
      
      
        Link Here
      
     | 
  
        
          | 72 | 
          ok(10 == scalar @shelves, 'created 10 lists'); # 10 shelves in @shelves;  | 
          73 | 
          ok(10 == scalar @shelves, 'created 10 lists'); # 10 shelves in @shelves;  | 
        
        
          | 73 | 
           | 
          74 | 
           | 
        
        
          | 74 | 
          # try to create some shelf which already exists.  | 
          75 | 
          # try to create some shelf which already exists.  | 
        
          
            
              | 75 | 
              for(my $i=0;$i<10;$i++){ | 
              76 | 
              for my $i(0..9){ | 
            
        
          | 76 | 
              my @shlf=GetShelf($shelves[$i]);  | 
          77 | 
              my @shlf=GetShelf($shelves[$i]);  | 
        
        
          | 77 | 
           | 
          78 | 
           | 
        
        
          | 78 | 
              # FIXME This test still needs some attention  | 
          79 | 
              # FIXME This test still needs some attention  | 
        
  
    | 
      
            Lines 95-101
          for(my $i=0;$i<10;$i++){
      
      
        Link Here
      
     | 
  
        
          | 95 | 
          # usage : $biblist = GetShelfContents($shelfnumber);  | 
          96 | 
          # usage : $biblist = GetShelfContents($shelfnumber);  | 
        
        
          | 96 | 
           | 
          97 | 
           | 
        
        
          | 97 | 
          my %used = ();  | 
          98 | 
          my %used = ();  | 
        
          
            
              | 98 | 
              for(my $i=0; $i<10;$i++){ | 
              99 | 
              for my $i(0..9){ | 
            
        
          | 99 | 
              my $bib = $biblionumbers[int(rand(9))];  | 
          100 | 
              my $bib = $biblionumbers[int(rand(9))];  | 
        
        
          | 100 | 
              my $shelfnumber = $shelves[int(rand(9))];  | 
          101 | 
              my $shelfnumber = $shelves[int(rand(9))];  | 
        
        
          | 101 | 
           | 
          102 | 
           | 
        
  
    | 
      
            Lines 125-132
          for(my $i=0; $i<10;$i++){
      
      
        Link Here
      
     | 
  
        
          | 125 | 
          #-----------------------TEST ModShelf & GetShelf functions------------------------#  | 
          126 | 
          #-----------------------TEST ModShelf & GetShelf functions------------------------#  | 
        
        
          | 126 | 
          # usage : ModShelf($shelfnumber, $shelfname, $owner, $category )  | 
          127 | 
          # usage : ModShelf($shelfnumber, $shelfname, $owner, $category )  | 
        
        
          | 127 | 
          # usage : (shelfnumber,shelfname,owner,category) = GetShelf($shelfnumber);  | 
          128 | 
          # usage : (shelfnumber,shelfname,owner,category) = GetShelf($shelfnumber);  | 
        
          
            
              | 128 | 
               | 
              129 | 
              for my $i(0..9){ | 
            
            
              | 129 | 
              for(my $i=0; $i<10;$i++){ | 
               | 
               | 
            
        
          | 130 | 
              my $rand = int(rand(9));  | 
          130 | 
              my $rand = int(rand(9));  | 
        
        
          | 131 | 
              my $numA = $shelves[$rand];  | 
          131 | 
              my $numA = $shelves[$rand];  | 
        
        
          | 132 | 
              my $shelf = { shelfname => "NewName_".$rand, | 
          132 | 
              my $shelf = { shelfname => "NewName_".$rand, | 
        
  
    | 
      
            Lines 140-153
          for(my $i=0; $i<10;$i++){
      
      
        Link Here
      
     | 
  
        
          | 140 | 
              ok($shelf->{category}  eq $categoryB, '... and category change took'); | 
          140 | 
              ok($shelf->{category}  eq $categoryB, '... and category change took'); | 
        
        
          | 141 | 
          }  | 
          141 | 
          }  | 
        
        
          | 142 | 
           | 
          142 | 
           | 
        
          
            
              | 143 | 
              #-----------------------TEST DelShelf & DelFromShelf functions------------------------#  | 
              143 | 
              $dbh->rollback;  | 
            
            
              | 144 | 
              # usage : ($status) = &DelShelf($shelfnumber);  | 
               | 
               | 
            
            
              | 145 | 
               | 
            
            
              | 146 | 
              for(my $i=0; $i<10;$i++){ | 
            
            
              | 147 | 
                  my $shelfnumber = $shelves[$i];  | 
            
            
              | 148 | 
                  my $status = DelShelf($shelfnumber);  | 
            
            
              | 149 | 
                  ok(1 == $status, "deleted shelf $shelfnumber and its contents");  | 
            
            
              | 150 | 
              }  | 
            
            
              | 151 | 
               | 
            
            
              | 152 | 
              #----------------------- CLEANUP ----------------------------------------------#  | 
            
            
              | 153 | 
              DelBiblio($_) for @biblionumbers;  | 
            
            
              | 154 | 
              -   | 
               | 
               |