Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Koha is free software; you can redistribute it and/or modify it |
6 |
# under the terms of the GNU General Public License as published by |
7 |
# the Free Software Foundation; either version 3 of the License, or |
8 |
# (at your option) any later version. |
9 |
# |
10 |
# Koha is distributed in the hope that it will be useful, but |
11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
# GNU General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
18 |
use Modern::Perl; |
19 |
|
20 |
use Test::More tests => 3; |
21 |
use Test::MockModule; |
22 |
use MARC::Record; |
23 |
|
24 |
use t::lib::TestBuilder; |
25 |
|
26 |
use C4::Biblio; |
27 |
use Koha::Database; |
28 |
|
29 |
BEGIN { |
30 |
use_ok('Koha::Biblio'); |
31 |
use_ok('Koha::Biblios'); |
32 |
} |
33 |
|
34 |
my $schema = Koha::Database->new->schema; |
35 |
$schema->storage->txn_begin; |
36 |
my $dbh = C4::Context->dbh; |
37 |
|
38 |
subtest 'Test Koha::Biblio::marc()' => sub { |
39 |
plan tests => 3; |
40 |
|
41 |
my $title = 'Oranges and Peaches'; |
42 |
|
43 |
my $record = MARC::Record->new(); |
44 |
my $field = MARC::Field->new('245','','','a' => $title); |
45 |
$record->append_fields( $field ); |
46 |
my ($biblionumber) = C4::Biblio::AddBiblio($record, ''); |
47 |
|
48 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
49 |
is( ref $biblio, 'Koha::Biblio', 'Found a Koha::Biblio object' ); |
50 |
|
51 |
my $marc = $biblio->marc(); |
52 |
is( ref $marc, 'MARC::Record', 'Method marc() returned a MARC::Record object' ); |
53 |
|
54 |
is( $marc->field('245')->subfield("a"), $title, 'Title in 245$a matches title from original record object' ); |
55 |
}; |
56 |
|
57 |
$schema->storage->txn_rollback; |