summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/bibtex/biber/t/18-bibtex-aliases.t
blob: 38b3f0230fbbe74fea6480b66156670025b2153a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use strict;
use warnings;
use utf8;
no warnings 'utf8';

use Test::More tests => 7;

use Biber;
use Biber::Output::BBL;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($ERROR);
chdir("t/tdata") ;

# Set up Biber object
my $biber = Biber->new(noconf => 1);
$biber->parse_ctrlfile('bibtex-aliases.bcf');
$biber->set_output_obj(Biber::Output::BBL->new());

# Options - we could set these in the control file but it's nice to see what we're
# relying on here for tests

# Biber options
Biber::Config->setoption('fastsort', 1);
Biber::Config->setoption('validate_structure', 1);

# Now generate the information
$biber->prepare;

my $section = $biber->sections->get_section(0);
my $bibentries = $section->bibentries;

my $w1 = ["Field 'school' is aliased to field 'institution' but both are defined in entry with key 'alias2' - skipping field 'school'",
          "Entry 'alias2' - invalid entry type 'thing' - defaulting to 'misc'",
          "Entry 'alias2' - invalid field 'institution' for entrytype 'misc'"
];

is($bibentries->entry('alias1')->get_field('entrytype'), 'thesis', 'Alias - 1' );
is($bibentries->entry('alias1')->get_field('type'), 'phdthesis', 'Alias - 2' );
is_deeply($bibentries->entry('alias1')->get_field('location'), ['Ivory Towers'], 'Alias - 3' );
is($bibentries->entry('alias1')->get_field('address'), undef, 'Alias - 4' );
is($bibentries->entry('alias2')->get_field('entrytype'), 'misc', 'Alias - 5' );
is_deeply($bibentries->entry('alias2')->get_field('warnings'), $w1, 'Alias - 6' ) ;
is($bibentries->entry('alias2')->get_field('school'), undef, 'Alias - 7' );

unlink <*.utf8>;