4 use Test::More tests => 2;
8 use C4::Utils::DataTables::ColumnsSettings;
11 my $schema = Koha::Database->new->schema;
12 $schema->storage->txn_begin;
13 my $dbh = C4::Context->dbh;
15 $dbh->do(q|DELETE FROM columns_settings|);
17 my $module = new Test::MockModule('C4::Utils::DataTables::ColumnsSettings');
25 'currencies-table' => [
27 columnname => 'currency',
28 cannot_be_toggled => '1',
29 cannot_be_modified => '1'
33 cannot_be_toggled => '1',
34 cannot_be_modified => '1'
37 columnname => 'symbol'
41 columnname => 'iso_code'
44 columnname => 'last_updated'
47 columnname => 'active'
50 columnname => 'actions'
61 C4::Utils::DataTables::ColumnsSettings::update_columns(
67 tablename => 'currencies-table',
68 columnname => 'currency',
69 cannot_be_toggled => 1,
70 cannot_be_modified => 1,
75 tablename => 'currencies-table',
77 cannot_be_toggled => 1,
78 cannot_be_modified => 1,
83 tablename => 'currencies-table',
84 columnname => 'symbol',
89 tablename => 'currencies-table',
90 columnname => 'iso_code',
96 tablename => 'currencies-table',
97 columnname => 'last_updated',
102 tablename => 'currencies-table',
103 columnname => 'active',
109 tablename => 'currencies-table',
110 columnname => 'actions',
111 cannot_be_toggled => 1,
117 my $modules = C4::Utils::DataTables::ColumnsSettings::get_modules();
119 my $modules_expected = {
122 'currencies-table' => [
124 columnname => 'currency',
125 cannot_be_toggled => 1,
126 cannot_be_modified => 1,
130 columnname => 'rate',
131 cannot_be_toggled => 1,
132 cannot_be_modified => 1,
136 columnname => 'symbol',
137 cannot_be_toggled => 0,
138 cannot_be_modified => 0,
142 columnname => 'iso_code',
143 cannot_be_toggled => 0,
144 cannot_be_modified => 0,
148 columnname => 'last_updated',
149 cannot_be_toggled => 0,
150 cannot_be_modified => 0,
154 columnname => 'active',
155 cannot_be_toggled => 0,
156 cannot_be_modified => 0,
160 columnname => 'actions',
161 cannot_be_toggled => 1,
162 cannot_be_modified => 0,
170 is_deeply( $modules, $modules_expected, 'get_modules returns all values' );
172 for my $m ( keys %$modules ) {
173 for my $p ( keys %{ $modules->{$m} } ) {
174 for my $t ( keys %{ $modules->{$m}{$p} } ) {
176 C4::Utils::DataTables::ColumnsSettings::get_columns( $m, $p, $t );
179 $modules->{$m}{$p}{$t},
180 "columns for $m>$p>$t"