4 use Test::More tests => 3;
8 use C4::Utils::DataTables::TablesSettings;
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 = Test::MockModule->new('C4::Utils::DataTables::TablesSettings');
25 'currencies-table' => {
26 default_display_length => 20,
27 default_sort_order => 1,
30 columnname => 'currency',
31 cannot_be_toggled => '1',
32 cannot_be_modified => '1'
36 cannot_be_toggled => '1',
37 cannot_be_modified => '1'
40 columnname => 'symbol'
44 columnname => 'iso_code'
47 columnname => 'last_updated'
50 columnname => 'active'
53 columnname => 'actions'
64 C4::Utils::DataTables::TablesSettings::update_columns(
70 tablename => 'currencies-table',
71 columnname => 'currency',
72 cannot_be_toggled => 1,
73 cannot_be_modified => 1,
78 tablename => 'currencies-table',
80 cannot_be_toggled => 1,
81 cannot_be_modified => 1,
86 tablename => 'currencies-table',
87 columnname => 'symbol',
92 tablename => 'currencies-table',
93 columnname => 'iso_code',
99 tablename => 'currencies-table',
100 columnname => 'last_updated',
105 tablename => 'currencies-table',
106 columnname => 'active',
112 tablename => 'currencies-table',
113 columnname => 'actions',
114 cannot_be_toggled => 1,
120 my $modules = C4::Utils::DataTables::TablesSettings::get_modules();
122 my $modules_expected = {
125 'currencies-table' => {
126 default_display_length => 20,
127 default_sort_order => 1,
130 columnname => 'currency',
131 cannot_be_toggled => 1,
132 cannot_be_modified => 1,
136 columnname => 'rate',
137 cannot_be_toggled => 1,
138 cannot_be_modified => 1,
142 columnname => 'symbol',
143 cannot_be_toggled => 0,
144 cannot_be_modified => 0,
148 columnname => 'iso_code',
149 cannot_be_toggled => 0,
150 cannot_be_modified => 0,
154 columnname => 'last_updated',
155 cannot_be_toggled => 0,
156 cannot_be_modified => 0,
160 columnname => 'active',
161 cannot_be_toggled => 0,
162 cannot_be_modified => 0,
166 columnname => 'actions',
167 cannot_be_toggled => 1,
168 cannot_be_modified => 0,
177 is_deeply( $modules, $modules_expected, 'get_modules returns all values' );
179 for my $m ( keys %$modules ) {
180 for my $p ( keys %{ $modules->{$m} } ) {
181 for my $t ( keys %{ $modules->{$m}{$p} } ) {
183 C4::Utils::DataTables::TablesSettings::get_columns( $m, $p, $t );
186 $modules->{$m}{$p}{$t}{columns},
187 "columns for $m>$p>$t"
190 C4::Utils::DataTables::TablesSettings::get_table_settings( $m, $p, $t );
193 default_display_length => $table_settings->{default_display_length},
194 default_sort_order => $table_settings->{default_sort_order}
197 default_display_length => $modules->{$m}{$p}{$t}{default_display_length},
198 default_sort_order => $modules->{$m}{$p}{$t}{default_sort_order},