Lines 10-15
use Koha::Virtualshelves;
Link Here
|
10 |
use Koha::Virtualshelfshares; |
10 |
use Koha::Virtualshelfshares; |
11 |
use Koha::Virtualshelfcontents; |
11 |
use Koha::Virtualshelfcontents; |
12 |
|
12 |
|
|
|
13 |
use t::lib::Dates; |
13 |
use t::lib::TestBuilder; |
14 |
use t::lib::TestBuilder; |
14 |
|
15 |
|
15 |
my $builder = t::lib::TestBuilder->new; |
16 |
my $builder = t::lib::TestBuilder->new; |
Lines 41-47
subtest 'CRUD' => sub {
Link Here
|
41 |
is( $number_of_shelves, 1, '1 shelf should have been inserted' ); |
42 |
is( $number_of_shelves, 1, '1 shelf should have been inserted' ); |
42 |
is( $shelf->allow_change_from_owner, 1, 'The default value for allow_change_from_owner should be 1' ); |
43 |
is( $shelf->allow_change_from_owner, 1, 'The default value for allow_change_from_owner should be 1' ); |
43 |
is( $shelf->allow_change_from_others, 0, 'The default value for allow_change_from_others should be 0' ); |
44 |
is( $shelf->allow_change_from_others, 0, 'The default value for allow_change_from_others should be 0' ); |
44 |
is( output_pref($shelf->created_on), output_pref(dt_from_string), 'The creation time should have been set to today' ); |
45 |
t::lib::Dates::compare( $shelf->created_on, dt_from_string, 'The creation time should have been set to today' ); |
45 |
|
46 |
|
46 |
# Test if creation date will not be overwritten by store |
47 |
# Test if creation date will not be overwritten by store |
47 |
my $created = dt_from_string->subtract( hours => 1 ); |
48 |
my $created = dt_from_string->subtract( hours => 1 ); |
Lines 51-57
subtest 'CRUD' => sub {
Link Here
|
51 |
my $retrieved_shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); |
52 |
my $retrieved_shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); |
52 |
|
53 |
|
53 |
is( $retrieved_shelf->shelfname, $shelf->shelfname, 'Find should correctly return the shelfname' ); |
54 |
is( $retrieved_shelf->shelfname, $shelf->shelfname, 'Find should correctly return the shelfname' ); |
54 |
is( dt_from_string($retrieved_shelf->created_on), $created, 'Creation date is the same after update (Bug 18672)' ); |
55 |
t::lib::Dates::compare( $retrieved_shelf->created_on, $created, 'Creation date is the same after update (Bug 18672)' ); |
55 |
|
56 |
|
56 |
# Insert with the same name |
57 |
# Insert with the same name |
57 |
eval { |
58 |
eval { |
Lines 181-191
subtest 'Shelf content' => sub {
Link Here
|
181 |
)->store; |
182 |
)->store; |
182 |
|
183 |
|
183 |
$shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); |
184 |
$shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); |
184 |
is( output_pref( dt_from_string $shelf->lastmodified ), output_pref($dt_yesterday), 'The lastmodified has been set to yesterday, will be useful for another test later' ); |
185 |
t::lib::Dates::compare( $shelf->lastmodified, $dt_yesterday, 'The lastmodified has been set to yesterday, will be useful for another test later' ); |
185 |
my $content1 = $shelf->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); |
186 |
my $content1 = $shelf->add_biblio( $biblio1->{biblionumber}, $patron1->{borrowernumber} ); |
186 |
is( ref($content1), 'Koha::Virtualshelfcontent', 'add_biblio to a shelf should return a Koha::Virtualshelfcontent object if inserted' ); |
187 |
is( ref($content1), 'Koha::Virtualshelfcontent', 'add_biblio to a shelf should return a Koha::Virtualshelfcontent object if inserted' ); |
187 |
$shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); |
188 |
$shelf = Koha::Virtualshelves->find( $shelf->shelfnumber ); |
188 |
is( output_pref( dt_from_string( $shelf->lastmodified ) ), output_pref(dt_from_string), 'Adding a biblio to a shelf should update the lastmodified for the shelf' ); |
189 |
t::lib::Dates::compare( $shelf->lastmodified, dt_from_string, 'Adding a biblio to a shelf should update the lastmodified for the shelf' ); |
189 |
my $content2 = $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); |
190 |
my $content2 = $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} ); |
190 |
$number_of_contents = Koha::Virtualshelfcontents->search->count; |
191 |
$number_of_contents = Koha::Virtualshelfcontents->search->count; |
191 |
is( $number_of_contents, 2, '2 biblio should have been inserted' ); |
192 |
is( $number_of_contents, 2, '2 biblio should have been inserted' ); |