|
Lines 73-83
subtest 'Test Koha::Biblio::Volume::add_item & Koha::Biblio::Volume::items' => s
Link Here
|
| 73 |
|
73 |
|
| 74 |
my $volume = Koha::Biblio::Volume->new( { biblionumber => $biblio->id } )->store(); |
74 |
my $volume = Koha::Biblio::Volume->new( { biblionumber => $biblio->id } )->store(); |
| 75 |
|
75 |
|
| 76 |
my @items = $volume->items; |
76 |
my $items = $volume->items; |
| 77 |
is( scalar(@items), 0, 'Volume has no items'); |
77 |
is( $items->count, 0, 'Volume has no items'); |
| 78 |
|
78 |
|
| 79 |
$volume->add_item({ item_id => $item_1->id }); |
79 |
$volume->add_item({ item_id => $item_1->id }); |
| 80 |
@items = $volume->items->as_list; |
80 |
my @items = $volume->items->as_list; |
| 81 |
is( scalar(@items), 1, 'Volume has one item'); |
81 |
is( scalar(@items), 1, 'Volume has one item'); |
| 82 |
is( $items[0]->id, $item_1->id, 'Item 1 is correct' ); |
82 |
is( $items[0]->id, $item_1->id, 'Item 1 is correct' ); |
| 83 |
|
83 |
|
|
Lines 117-123
subtest 'Test Koha::Item::volume' => sub {
Link Here
|
| 117 |
|
117 |
|
| 118 |
subtest 'Koha::Item::delete should delete volume if no other items are using the volume' => sub { |
118 |
subtest 'Koha::Item::delete should delete volume if no other items are using the volume' => sub { |
| 119 |
|
119 |
|
| 120 |
plan tests => 8; |
120 |
plan tests => 11; |
| 121 |
|
121 |
|
| 122 |
$schema->storage->txn_begin; |
122 |
$schema->storage->txn_begin; |
| 123 |
|
123 |
|
|
Lines 137-147
subtest 'Koha::Item::delete should delete volume if no other items are using the
Link Here
|
| 137 |
my $volume = Koha::Biblio::Volumes->find( $volume_1->id ); |
137 |
my $volume = Koha::Biblio::Volumes->find( $volume_1->id ); |
| 138 |
is( $volume->id, $volume_1->id, 'Found the correct volume'); |
138 |
is( $volume->id, $volume_1->id, 'Found the correct volume'); |
| 139 |
|
139 |
|
|
|
140 |
is( $item_1->volume->id, $volume_1->id, 'Item 1 has correct volume'); |
| 141 |
is( $item_2->volume->id, $volume_1->id, 'Item 2 has correct volume'); |
| 142 |
|
| 140 |
$item_1->delete(); |
143 |
$item_1->delete(); |
| 141 |
is( $biblio->items->count, 1, 'Bib has 2 item'); |
144 |
is( $biblio->items->count, 1, 'Bib has 2 item'); |
| 142 |
$volume = Koha::Biblio::Volumes->find( $volume_1->id ); |
145 |
$volume = Koha::Biblio::Volumes->find( $volume_1->id ); |
| 143 |
is( $volume->id, $volume_1->id, 'Volume still exists after deleting and item, but other items remain'); |
146 |
is( $volume->id, $volume_1->id, 'Volume still exists after deleting and item, but other items remain'); |
| 144 |
|
147 |
|
|
|
148 |
is( $item_2->volume->id, $volume_1->id, 'Item 2 still has correct volume'); |
| 149 |
|
| 145 |
$item_2->delete(); |
150 |
$item_2->delete(); |
| 146 |
is( $biblio->items->count, 0, 'Bib has 0 items'); |
151 |
is( $biblio->items->count, 0, 'Bib has 0 items'); |
| 147 |
$volume = Koha::Biblio::Volumes->find( $volume_1->id ); |
152 |
$volume = Koha::Biblio::Volumes->find( $volume_1->id ); |
| 148 |
- |
|
|