4 use Test::More tests => 2;
8 use C4::Utils::DataTables::ColumnsSettings;
9 my $dbh = C4::Context->dbh;
10 $dbh->{AutoCommit} = 0;
11 $dbh->{RaiseError} = 1;
13 $dbh->do(q|DELETE FROM columns_settings|);
15 my $module = new Test::MockModule('C4::Utils::DataTables::ColumnsSettings');
23 'currencies-table' => [
25 columnname => 'currency',
26 cannot_be_toggled => '1',
27 cannot_be_modified => '1'
31 cannot_be_toggled => '1',
32 cannot_be_modified => '1'
35 columnname => 'symbol'
39 columnname => 'iso_code'
42 columnname => 'last_updated'
45 columnname => 'active'
48 columnname => 'actions'
59 C4::Utils::DataTables::ColumnsSettings::update_columns(
65 tablename => 'currencies-table',
66 columnname => 'currency',
67 cannot_be_toggled => 1,
68 cannot_be_modified => 1,
73 tablename => 'currencies-table',
75 cannot_be_toggled => 1,
76 cannot_be_modified => 1,
81 tablename => 'currencies-table',
82 columnname => 'symbol',
87 tablename => 'currencies-table',
88 columnname => 'iso_code',
94 tablename => 'currencies-table',
95 columnname => 'last_updated',
100 tablename => 'currencies-table',
101 columnname => 'active',
107 tablename => 'currencies-table',
108 columnname => 'actions',
109 cannot_be_toggled => 1,
115 my $modules = C4::Utils::DataTables::ColumnsSettings::get_modules();
117 my $modules_expected = {
120 'currencies-table' => [
122 columnname => 'currency',
123 cannot_be_toggled => 1,
124 cannot_be_modified => 1,
128 columnname => 'rate',
129 cannot_be_toggled => 1,
130 cannot_be_modified => 1,
134 columnname => 'symbol',
135 cannot_be_toggled => 0,
136 cannot_be_modified => 0,
140 columnname => 'iso_code',
141 cannot_be_toggled => 0,
142 cannot_be_modified => 0,
146 columnname => 'last_updated',
147 cannot_be_toggled => 0,
148 cannot_be_modified => 0,
152 columnname => 'active',
153 cannot_be_toggled => 0,
154 cannot_be_modified => 0,
158 columnname => 'actions',
159 cannot_be_toggled => 1,
160 cannot_be_modified => 0,
168 is_deeply( $modules, $modules_expected, 'get_modules returns all values' );
170 for my $m ( keys %$modules ) {
171 for my $p ( keys %{ $modules->{$m} } ) {
172 for my $t ( keys %{ $modules->{$m}{$p} } ) {
174 C4::Utils::DataTables::ColumnsSettings::get_columns( $m, $p, $t );
177 $modules->{$m}{$p}{$t},
178 "columns for $m>$p>$t"