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

(-)a/admin/columns_settings.yml (-5 / +18 lines)
Lines 1-10 Link Here
1
modules:
1
modules:
2
  module_name:
2
  admin:
3
    page_name:
3
    currency:
4
      table_id:
4
      currencies-table:
5
        -
5
        -
6
          columnname: my_column_name
6
          columnname: currency
7
          cannot_be_toggled: 1
8
          cannot_be_modified: 1
7
        -
9
        -
8
          columnname: my_other_column_name
10
          columnname: rate
9
          cannot_be_toggled: 1
11
          cannot_be_toggled: 1
10
          cannot_be_modified: 1
12
          cannot_be_modified: 1
13
        -
14
          columnname: symbol
15
        -
16
          columnname: iso_code
17
          is_hidden: 1
18
        -
19
          columnname: last_updated
20
        -
21
          columnname: active
22
        -
23
          columnname: actions
(-)a/t/db_dependent/ColumnsSettings.t (-1 / +179 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl;
2
3
use Modern::Perl;
4
use Test::More tests => 2;
5
use Test::MockModule;
6
7
use C4::Context;
8
use C4::Utils::DataTables::ColumnsSettings;
9
my $dbh = C4::Context->dbh;
10
$dbh->{AutoCommit} = 0;
11
$dbh->{RaiseError} = 1;
12
13
$dbh->do(q|DELETE FROM columns_settings|);
14
15
my $module = new Test::MockModule('C4::Utils::DataTables::ColumnsSettings');
16
$module->mock(
17
    'get_yaml',
18
    sub {
19
        {
20
            modules => {
21
                admin => {
22
                    currency => {
23
                        'currencies-table' => [
24
                            {
25
                                columnname         => 'currency',
26
                                cannot_be_toggled  => '1',
27
                                cannot_be_modified => '1'
28
                            },
29
                            {
30
                                columnname         => 'rate',
31
                                cannot_be_toggled  => '1',
32
                                cannot_be_modified => '1'
33
                            },
34
                            {
35
                                columnname => 'symbol'
36
                            },
37
                            {
38
                                is_hidden  => '1',
39
                                columnname => 'iso_code'
40
                            },
41
                            {
42
                                columnname => 'last_updated'
43
                            },
44
                            {
45
                                columnname => 'active'
46
                            },
47
                            {
48
                                columnname => 'actions'
49
                            }
50
                        ]
51
                    }
52
                }
53
              }
54
55
        };
56
    }
57
);
58
59
C4::Utils::DataTables::ColumnsSettings::update_columns(
60
    {
61
        columns => [
62
            {
63
                module             => 'admin',
64
                page               => 'currency',
65
                tablename          => 'currencies-table',
66
                columnname         => 'currency',
67
                cannot_be_toggled  => 1,
68
                cannot_be_modified => 1,
69
            },
70
            {
71
                module             => 'admin',
72
                page               => 'currency',
73
                tablename          => 'currencies-table',
74
                columnname         => 'rate',
75
                cannot_be_toggled  => 1,
76
                cannot_be_modified => 1,
77
            },
78
            {
79
                module     => 'admin',
80
                page       => 'currency',
81
                tablename  => 'currencies-table',
82
                columnname => 'symbol',
83
            },
84
            {
85
                module     => 'admin',
86
                page       => 'currency',
87
                tablename  => 'currencies-table',
88
                columnname => 'iso_code',
89
                is_hidden  => 0,
90
            },
91
            {
92
                module     => 'admin',
93
                page       => 'currency',
94
                tablename  => 'currencies-table',
95
                columnname => 'last_updated',
96
            },
97
            {
98
                module     => 'admin',
99
                page       => 'currency',
100
                tablename  => 'currencies-table',
101
                columnname => 'active',
102
                is_hidden  => 1,
103
            },
104
            {
105
                module            => 'admin',
106
                page              => 'currency',
107
                tablename         => 'currencies-table',
108
                columnname        => 'actions',
109
                cannot_be_toggled => 1,
110
            },
111
        ]
112
    }
113
);
114
115
my $modules = C4::Utils::DataTables::ColumnsSettings::get_modules();
116
117
my $modules_expected = {
118
    'admin' => {
119
        'currency' => {
120
            'currencies-table' => [
121
                {
122
                    columnname         => 'currency',
123
                    cannot_be_toggled  => 1,
124
                    cannot_be_modified => 1,
125
                    is_hidden  => 0,
126
                },
127
                {
128
                    columnname         => 'rate',
129
                    cannot_be_toggled  => 1,
130
                    cannot_be_modified => 1,
131
                    is_hidden  => 0,
132
                },
133
                {
134
                    columnname => 'symbol',
135
                    cannot_be_toggled  => 0,
136
                    is_hidden  => 0,
137
                },
138
                {
139
                    columnname => 'iso_code',
140
                    cannot_be_toggled  => 0,
141
                    is_hidden  => 0,
142
                },
143
                {
144
                    columnname => 'last_updated',
145
                    cannot_be_toggled  => 0,
146
                    is_hidden  => 0,
147
                },
148
                {
149
                    columnname => 'active',
150
                    cannot_be_toggled  => 0,
151
                    is_hidden  => 1,
152
                },
153
                {
154
                    columnname        => 'actions',
155
                    cannot_be_toggled => 1,
156
                    is_hidden  => 0,
157
                },
158
            ]
159
        }
160
    }
161
};
162
163
is_deeply( $modules, $modules_expected, 'get_modules returns all values' );
164
165
for my $m ( keys %$modules ) {
166
    for my $p ( keys %{ $modules->{$m} } ) {
167
        for my $t ( keys %{ $modules->{$m}{$p} } ) {
168
            my $columns =
169
              C4::Utils::DataTables::ColumnsSettings::get_columns( $m, $p, $t );
170
            is_deeply(
171
                $columns,
172
                $modules->{$m}{$p}{$t},
173
                "columns for $m>$p>$t"
174
            );
175
        }
176
    }
177
}
178
179
$dbh->rollback;

Return to bug 10212