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,
139 columnname => 'iso_code',
140 cannot_be_toggled => 0,
144 columnname => 'last_updated',
145 cannot_be_toggled => 0,
149 columnname => 'active',
150 cannot_be_toggled => 0,
154 columnname => 'actions',
155 cannot_be_toggled => 1,
163 is_deeply( $modules, $modules_expected, 'get_modules returns all values' );
165 for my $m ( keys %$modules ) {
166 for my $p ( keys %{ $modules->{$m} } ) {
167 for my $t ( keys %{ $modules->{$m}{$p} } ) {
169 C4::Utils::DataTables::ColumnsSettings::get_columns( $m, $p, $t );
172 $modules->{$m}{$p}{$t},
173 "columns for $m>$p>$t"