View | Details | Raw Unified | Return to bug 15517
Collapse All | Expand All

(-)a/t/db_dependent/db_structure.t (-1 / +43 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
use Test::More tests => 409;
4
use Koha::Database;
5
6
my @modules = (
7
    [ qw( Borrower Deletedborrower ) ],
8
    [ qw( Biblio Deletedbiblio ) ],
9
    [ qw( Biblioitem Deletedbiblioitem ) ],
10
    [ qw( Item Deleteditem ) ],
11
);
12
13
my @keys_to_check = qw( size is_nullable data_type accessor datetime_undef_if_invalid default_value );
14
15
for my $modules ( @modules ) {
16
    my $rs_1 = Koha::Database->new->schema->resultset($modules->[0]);
17
    my $rs_2 = Koha::Database->new->schema->resultset($modules->[1]);
18
    my $col_infos_1 = $rs_1->result_source->columns_info;
19
    my $col_infos_2 = $rs_2->result_source->columns_info;
20
    while ( my ( $column_name, $column_infos ) = each %$col_infos_1 ) {
21
        while ( my ( $column_attribute, $value ) = each %$column_infos ) {
22
            if ( grep {$_ eq $column_attribute} @keys_to_check ) {
23
                my $val_1 = $col_infos_1->{$column_name}{$column_attribute};
24
                my $val_2 = $col_infos_2->{$column_name}{$column_attribute};
25
                # Dereference if we got a reference to a scalar
26
                if ( ref($val_1) eq 'SCALAR' ) {
27
                    $val_1 = ${$val_1};
28
                    $val_2 = ${$val_2};
29
                }
30
31
                if ( ref($val_1) eq 'ARRAY') {
32
                    is_deeply( $val_1, $val_2,
33
                        "tables related to $modules->[0] and $modules->[1] differs on $column_name.$column_attribute"
34
                    );
35
                } else {
36
                    is( $val_1, $val_2,
37
                        "tables related to $modules->[0] and $modules->[1] differs on $column_name.$column_attribute"
38
                    );
39
                }
40
            }
41
        }
42
    }
43
}

Return to bug 15517