Bug 20434: Update UNIMARC framework - authorised values
[koha.git] / t / db_dependent / db_structure.t
blob41de50750c74737b214fc812fc99ef6b08d95244
1 #!/usr/bin/perl
3 # This file is part of Koha.
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.
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.
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>.
18 use Modern::Perl;
20 use Test::More;
21 use Koha::Database;
23 my @modules = (
24 [ qw( Borrower Deletedborrower ) ],
25 [ qw( Biblio Deletedbiblio ) ],
26 [ qw( Biblioitem Deletedbiblioitem ) ],
27 [ qw( Item Deleteditem ) ],
30 my @keys_to_check = qw( size is_nullable data_type accessor datetime_undef_if_invalid default_value );
32 for my $modules ( @modules ) {
33 my $rs_1 = Koha::Database->new->schema->resultset($modules->[0]);
34 my $rs_2 = Koha::Database->new->schema->resultset($modules->[1]);
35 my $col_infos_1 = $rs_1->result_source->columns_info;
36 my $col_infos_2 = $rs_2->result_source->columns_info;
37 while ( my ( $column_name, $column_infos ) = each %$col_infos_1 ) {
38 while ( my ( $column_attribute, $value ) = each %$column_infos ) {
39 if ( grep {$_ eq $column_attribute} @keys_to_check ) {
40 my $val_1 = $col_infos_1->{$column_name}{$column_attribute};
41 my $val_2 = $col_infos_2->{$column_name}{$column_attribute};
42 # Dereference if we got a reference to a scalar
43 if ( ref($val_1) eq 'SCALAR' ) {
44 $val_1 = ${$val_1};
45 $val_2 = ${$val_2};
48 if ( ref($val_1) eq 'ARRAY') {
49 is_deeply( $val_1, $val_2,
50 "tables related to $modules->[0] and $modules->[1] should not differ on $column_name.$column_attribute"
52 } else {
53 is( $val_1, $val_2,
54 "tables related to $modules->[0] and $modules->[1] should not differ on $column_name.$column_attribute"
62 done_testing();