Lines 9-15
use strict;
Link Here
|
9 |
use warnings; |
9 |
use warnings; |
10 |
use C4::Context; |
10 |
use C4::Context; |
11 |
|
11 |
|
12 |
use Test::More tests => 92; |
12 |
use Test::More tests => 82; |
13 |
|
13 |
|
14 |
# Getting some borrowers from database. |
14 |
# Getting some borrowers from database. |
15 |
my $dbh = C4::Context->dbh; |
15 |
my $dbh = C4::Context->dbh; |
Lines 66-72
use_ok('C4::VirtualShelves');
Link Here
|
66 |
# creating 10 good shelves. |
66 |
# creating 10 good shelves. |
67 |
my @shelves; |
67 |
my @shelves; |
68 |
for(my $i=0; $i<10;$i++){ |
68 |
for(my $i=0; $i<10;$i++){ |
69 |
my $ShelfNumber = AddShelf("Shelf_".$i,$borrowers[$i] || '',int(rand(3))+1); |
69 |
my $ShelfNumber = AddShelf( |
|
|
70 |
{shelfname=>"Shelf_".$i, category=>int(rand(2))+1 }, $borrowers[$i] ); |
70 |
die "test Not ok, remove some shelves before" if ($ShelfNumber == -1); |
71 |
die "test Not ok, remove some shelves before" if ($ShelfNumber == -1); |
71 |
ok($ShelfNumber > -1, "created shelf"); # Shelf creation successful; |
72 |
ok($ShelfNumber > -1, "created shelf"); # Shelf creation successful; |
72 |
push @shelves, $ShelfNumber if $ShelfNumber > -1; |
73 |
push @shelves, $ShelfNumber if $ShelfNumber > -1; |
Lines 76-82
ok(10 == scalar @shelves, 'created 10 lists'); # 10 shelves in @shelves;
Link Here
|
76 |
|
77 |
|
77 |
# try to create some shelf which already exists. |
78 |
# try to create some shelf which already exists. |
78 |
for(my $i=0;$i<10;$i++){ |
79 |
for(my $i=0;$i<10;$i++){ |
79 |
my $badNumShelf = AddShelf("Shelf_".$i,$borrowers[$i] || '',''); |
80 |
my @shlf=GetShelf($shelves[$i]); |
|
|
81 |
my $badNumShelf = AddShelf( |
82 |
{shelfname=>"Shelf_".$i, category=>$shlf[3] }, $borrowers[$i]); |
80 |
ok(-1 == $badNumShelf, 'do not create lists with duplicate names'); # AddShelf returns -1 if name already exist. |
83 |
ok(-1 == $badNumShelf, 'do not create lists with duplicate names'); # AddShelf returns -1 if name already exist. |
81 |
} |
84 |
} |
82 |
|
85 |
|
Lines 94-100
for(my $i=0; $i<10;$i++){
Link Here
|
94 |
my $should_fail = exists($used{$key}) ? 1 : 0; |
97 |
my $should_fail = exists($used{$key}) ? 1 : 0; |
95 |
|
98 |
|
96 |
my ($biblistBefore,$countbefore) = GetShelfContents($shelfnumber); |
99 |
my ($biblistBefore,$countbefore) = GetShelfContents($shelfnumber); |
97 |
my $status = AddToShelf($bib,$shelfnumber); |
100 |
my $status = AddToShelf($bib,$shelfnumber,$borrowers[$i]); |
98 |
my ($biblistAfter,$countafter) = GetShelfContents($shelfnumber); |
101 |
my ($biblistAfter,$countafter) = GetShelfContents($shelfnumber); |
99 |
|
102 |
|
100 |
if ($should_fail) { |
103 |
if ($should_fail) { |
Lines 121-135
for(my $i=0; $i<10;$i++){
Link Here
|
121 |
my $rand = int(rand(9)); |
124 |
my $rand = int(rand(9)); |
122 |
my $numA = $shelves[$rand]; |
125 |
my $numA = $shelves[$rand]; |
123 |
my $shelf = { shelfname => "NewName_".$rand, |
126 |
my $shelf = { shelfname => "NewName_".$rand, |
124 |
owner => $borrowers[$rand], |
127 |
category => int(rand(2))+1 }; |
125 |
category => int(rand(3))+1 }; |
|
|
126 |
|
128 |
|
127 |
ModShelf($numA,$shelf); |
129 |
ModShelf($numA,$shelf); |
128 |
my ($numB,$nameB,$ownerB,$categoryB) = GetShelf($numA); |
130 |
my ($numB,$nameB,$ownerB,$categoryB) = GetShelf($numA); |
129 |
|
131 |
|
130 |
ok($numA == $numB, 'modified shelf'); |
132 |
ok($numA == $numB, 'modified shelf'); |
131 |
ok($shelf->{shelfname} eq $nameB, '... and name change took'); |
133 |
ok($shelf->{shelfname} eq $nameB, '... and name change took'); |
132 |
ok($shelf->{owner} eq $ownerB, '... and owner change took'); |
|
|
133 |
ok($shelf->{category} eq $categoryB, '... and category change took'); |
134 |
ok($shelf->{category} eq $categoryB, '... and category change took'); |
134 |
} |
135 |
} |
135 |
|
136 |
|
136 |
- |
|
|