| 1 | package CGI::Widget::DBI::Search::Display::TEST::Grid; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use base qw/ CGI::Widget::DBI::TEST::Search /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | |||
| 7 | sub init_test_object | ||
| 8 | 0 | ▶ | { |
|
Subroutine
init_test_object: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 9 | 0 | my $self = shift; | |
| 10 | 0 | $self->SUPER::init_test_object(); | |
| 11 | 0 | $self->{ws}->{-display_mode} = 'grid'; | |
| 12 | 0 | $self->{ws}->{-grid_columns} = 2; | |
| 13 | } | ||
| 14 | |||
| 15 | 0 | ▶ | sub test_display_results {} |
|
Subroutine
test_display_results: not called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 16 | |||
| 17 | sub test_search__basic | ||
| 18 | 0 | ▶ | { |
|
Subroutine
test_search__basic: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 19 | 0 | my $self = shift; | |
| 20 | # TODO: move these superclass calls into set_up method | ||
| 21 | 0 | $self->SUPER::test_search__basic; | |
| 22 | |||
| 23 | 0 | $self->assert_display_contains( | |
| 24 | [ 'tr', 'td' ], | ||
| 25 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 26 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 27 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 28 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 29 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 30 | [ 'td', 'tr' ], | ||
| 31 | ); | ||
| 32 | } | ||
| 33 | |||
| 34 | sub test_search__display_only_subset_of_columns | ||
| 35 | 0 | ▶ | { |
|
Subroutine
test_search__display_only_subset_of_columns: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 36 | 0 | my $self = shift; | |
| 37 | 0 | $self->{ws}->{-display_columns} = { map {$_ => $_} qw/widget_no name size/ }; | |
| 38 | 0 | $self->SUPER::test_search__basic; | |
| 39 | |||
| 40 | 0 | $self->assert_display_contains( | |
| 41 | [ 'tr', 'td' ], | ||
| 42 | [ 1, 'clock_widget', 'small' ], | ||
| 43 | [ 2, 'calendar_widget', 'medium' ], | ||
| 44 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 45 | [ 3, 'silly_widget', 'unknown' ], | ||
| 46 | [ 4, 'gps_widget', 'medium' ], | ||
| 47 | [ 'td', 'tr' ], | ||
| 48 | ); | ||
| 49 | 0 | $self->assert_display_does_not_contain( [ 'A time keeper widget', ] ); | |
| 50 | 0 | $self->assert_display_does_not_contain( [ 'A date tracker widget', ] ); | |
| 51 | 0 | $self->assert_display_does_not_contain( [ 'A goofball widget', ] ); | |
| 52 | } | ||
| 53 | |||
| 54 | sub test_search__display_nondb_columns_and_columndata_closures | ||
| 55 | 0 | ▶ | { |
|
Subroutine
test_search__display_nondb_columns_and_columndata_closures: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 56 | 0 | my $self = shift; | |
| 57 | 0 | $self->{ws}->{-pre_nondb_columns} = [qw/my_header1/]; | |
| 58 | 0 | $self->{ws}->{-post_nondb_columns} = [qw/my_header2 my_header3/]; | |
| 59 | $self->{ws}->{-columndata_closures} = { | ||
| 60 | 0 | ▶ | my_header1 => sub { my ($self, $row) = @_; return "Widget #".$row->{widget_no}; }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 61 | 0 | ▶ | my_header2 => sub { my ($self, $row) = @_; return "Widget Size: ".$row->{size}; }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 62 | 0 | ▶ | my_header3 => sub { return "a***b"; }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 63 | 0 | }; | |
| 64 | 0 | $self->SUPER::test_search__basic; | |
| 65 | |||
| 66 | 0 | $self->assert_display_contains( | |
| 67 | [ 'tr', 'td' ], | ||
| 68 | [ 'Widget #1', 1, 'clock_widget', 'A time keeper widget', 'small', 'Widget Size', 'small', 'my_header3', 'a\*\*\*b', ], | ||
| 69 | [ 'Widget #2', 2, 'calendar_widget', 'A date tracker widget', 'medium', 'Widget Size', 'medium', 'my_header3', 'a\*\*\*b', ], | ||
| 70 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 71 | [ 'Widget #3', 3, 'silly_widget', 'A goofball widget', 'unknown', 'Widget Size', 'unknown', 'my_header3', 'a\*\*\*b', ], | ||
| 72 | [ 'td', 'tr' ], | ||
| 73 | ); | ||
| 74 | } | ||
| 75 | |||
| 76 | sub test_search__with_a_join | ||
| 77 | 0 | ▶ | { |
|
Subroutine
test_search__with_a_join: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 78 | 0 | my $self = shift; | |
| 79 | 0 | $self->SUPER::test_search__with_a_join; | |
| 80 | |||
| 81 | 0 | $self->assert_display_contains( | |
| 82 | [ 'div', 'align', 'right', 'Sort by', 'sortby_columns_popup', 'Sort field', | ||
| 83 | 'sortby=widget_no', 'widget_no', 'sortby=name', 'name', | ||
| 84 | 'sortby=description', 'description', 'sortby=size', 'size', | ||
| 85 | 'sortby=tool_no', 'tool_no', 'sortby=tool_name', 'tool_name', | ||
| 86 | 'sortby=type', 'type', ], | ||
| 87 | [ 'tr', 'td' ], | ||
| 88 | [ 1, 'clock_widget', 'A time keeper widget', 'small', 2, 'wrench', 'hand' ], | ||
| 89 | [ 1, 'clock_widget', 'A time keeper widget', 'small', 1, 'hammer', 'hand' ], | ||
| 90 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 91 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium', 5, 'emacs', 'software' ], | ||
| 92 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium', 6, 'apache', 'software' ], | ||
| 93 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 94 | [ 3, 'silly_widget', 'A goofball widget', 'unknown', 4, 'rm', 'unix' ], | ||
| 95 | [ 'td', 'tr' ], | ||
| 96 | ); | ||
| 97 | } | ||
| 98 | |||
| 99 | sub test_search__with_a_filter | ||
| 100 | 0 | ▶ | { |
|
Subroutine
test_search__with_a_filter: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 101 | 0 | my $self = shift; | |
| 102 | 0 | $self->SUPER::test_search__with_a_filter; | |
| 103 | |||
| 104 | # only displays most recent filter | ||
| 105 | 0 | $self->assert_display_contains( | |
| 106 | [ 'tr', 'td' ], | ||
| 107 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 108 | [ 'td', 'tr' ], | ||
| 109 | ); | ||
| 110 | } | ||
| 111 | |||
| 112 | sub test_search__paging | ||
| 113 | 0 | ▶ | { |
|
Subroutine
test_search__paging: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 114 | 0 | my $self = shift; | |
| 115 | 0 | $self->SUPER::test_search__paging; | |
| 116 | |||
| 117 | # only displays most recent page of search | ||
| 118 | 0 | $self->assert_display_contains( | |
| 119 | [ 'search_startat=0', 'First', 'search_startat=1', 'Previous', | ||
| 120 | '1', 'result displayed', '5 - 5', 'of', '5', 'At last page' ], | ||
| 121 | [ 'tr', 'td' ], | ||
| 122 | [ 3, 'silly_widget', 'A goofball widget', 'unknown', 4, 'rm', 'unix' ], | ||
| 123 | [ 'td', 'tr' ], | ||
| 124 | [ 'search_startat=0', 'First', 'search_startat=1', 'Previous', | ||
| 125 | 'Skip to page', '0', '1', '2', 'At last page' ], | ||
| 126 | ); | ||
| 127 | } | ||
| 128 | |||
| 129 | sub test_search__sorting | ||
| 130 | 0 | ▶ | { |
|
Subroutine
test_search__sorting: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 131 | 0 | my $self = shift; | |
| 132 | 0 | $self->SUPER::test_search__sorting; | |
| 133 | |||
| 134 | # only displays most recent sorting | ||
| 135 | 0 | $self->assert_display_contains( | |
| 136 | [ 'div', 'align', 'right', 'Sort by', 'sortby_columns_popup', | ||
| 137 | 'sortby=widget_no', 'widget_no', 'sortby=name', 'name', | ||
| 138 | 'sortby=description', 'description', 'sortby=size', 'size' ], | ||
| 139 | [ 'tr', 'td' ], | ||
| 140 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 141 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 142 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 143 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 144 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 145 | [ 'td', 'tr' ], | ||
| 146 | ); | ||
| 147 | } | ||
| 148 | |||
| 149 | sub test_search__sorting__supports_href_and_form_extra_vars | ||
| 150 | 0 | ▶ | { |
|
Subroutine
test_search__sorting__supports_href_and_form_extra_vars: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 151 | 0 | my $self = shift; | |
| 152 | 0 | my $ws = $self->{ws}; | |
| 153 | |||
| 154 | 0 | $self->_setup_test_search__sorting(); | |
| 155 | 0 | $ws->{q}->param('href_testvar', 'foo'); | |
| 156 | 0 | $ws->{q}->param('form_hiddenvar', 'bar'); | |
| 157 | 0 | $ws->{-href_extra_vars} = { href_testvar => undef }; | |
| 158 | 0 | $ws->{-form_extra_vars} = { form_hiddenvar => undef }; | |
| 159 | 0 | $ws->search(); | |
| 160 | |||
| 161 | # only displays most recent sorting | ||
| 162 | 0 | $self->assert_display_contains( | |
| 163 | [ 'input type="hidden" name="form_hiddenvar" value="bar' ], | ||
| 164 | [ 'div', 'align', 'right', 'Sort by', 'sortby_columns_popup', | ||
| 165 | 'sortby=widget_no&href_testvar=foo', 'widget_no', 'sortby=name&href_testvar=foo', 'name', | ||
| 166 | 'sortby=description&href_testvar=foo', 'description', 'sortby=size&href_testvar=foo', 'size' ], | ||
| 167 | [ 'tr', 'td' ], | ||
| 168 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 169 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 170 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 171 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 172 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 173 | [ 'td', 'tr' ], | ||
| 174 | ); | ||
| 175 | } | ||
| 176 | |||
| 177 | sub test_search__sorting_in_action_uri_js_function_mode__supports_href_and_form_extra_vars | ||
| 178 | 0 | ▶ | { |
|
Subroutine
test_search__sorting_in_action_uri_js_function_mode__supports_href_and_form_extra_vars: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 179 | 0 | my $self = shift; | |
| 180 | 0 | my $ws = $self->{ws}; | |
| 181 | |||
| 182 | 0 | $self->_setup_test_search__sorting(); | |
| 183 | 0 | $ws->{q}->param('href_testvar', 'foo'); | |
| 184 | 0 | $ws->{q}->param('form_hiddenvar', 'bar'); | |
| 185 | 0 | $ws->{-href_extra_vars} = { href_testvar => undef }; | |
| 186 | 0 | $ws->{-form_extra_vars} = { form_hiddenvar => undef }; | |
| 187 | 0 | $ws->{-action_uri_js_function} = 'myCustomFunc'; | |
| 188 | 0 | $ws->search(); | |
| 189 | |||
| 190 | # only displays most recent sorting | ||
| 191 | $self->assert_display_contains( | ||
| 192 | [ 'input type="hidden" name="form_hiddenvar" value="bar' ], | ||
| 193 | [ 'div', 'align', 'right', 'Sort by', 'sortby_columns_popup', ], | ||
| 194 | 0 | [ map { ("\QmyCustomFunc({ 'sortby': '$_', 'href_testvar': 'foo'\E", $_) } qw/widget_no name description size/ ], | |
| 195 | [ 'tr', 'td' ], | ||
| 196 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 197 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 198 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 199 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 200 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 201 | [ 'td', 'tr' ], | ||
| 202 | ); | ||
| 203 | } | ||
| 204 | |||
| 205 | sub test_search__only_allows_sorting_by_specified_columns | ||
| 206 | 0 | ▶ | { |
|
Subroutine
test_search__only_allows_sorting_by_specified_columns: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 207 | 0 | my $self = shift; | |
| 208 | 0 | my $ws = $self->{ws}; | |
| 209 | |||
| 210 | 0 | $self->_setup_test_search__sorting(); | |
| 211 | 0 | $ws->{q}->param('sortby', 'widget_no'); | |
| 212 | |||
| 213 | 0 | $ws->{-unsortable_columns} = {size => 1}; | |
| 214 | 0 | $ws->search(); | |
| 215 | |||
| 216 | 0 | $self->assert_display_contains( | |
| 217 | [ 'div', 'align', 'right', 'Sort by', 'sortby_columns_popup', | ||
| 218 | 'sortby=widget_no', 'widget_no', 'sortby=name', 'name', | ||
| 219 | 'sortby=description', 'description' ], | ||
| 220 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 221 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 222 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 223 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 224 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 225 | [ 'td', 'tr' ], | ||
| 226 | ); | ||
| 227 | 0 | $self->assert_display_does_not_contain([ 'sortby=size', 'size' ]); | |
| 228 | |||
| 229 | # reset and search again | ||
| 230 | 0 | $self->init_test_object(); | |
| 231 | 0 | $self->_setup_test_search__sorting(); | |
| 232 | 0 | $ws = $self->{ws}; | |
| 233 | 0 | $ws->{q}->param('sortby', 'widget_no'); | |
| 234 | 0 | $ws->{q}->param('sort_reverse', 1); | |
| 235 | |||
| 236 | 0 | $ws->{-sortable_columns} = {widget_no => 1, name => 1}; | |
| 237 | 0 | $ws->search(); | |
| 238 | |||
| 239 | 0 | $self->assert_display_contains( | |
| 240 | [ 'div align="right', 'Sort by', 'sortby_columns_popup' ], | ||
| 241 | [ 'option value="\?sortby=name">name' ], | ||
| 242 | [ 'option selected="selected" value="\?sortby=widget_no&sort_reverse=0">widget_no', ], | ||
| 243 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 244 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 245 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 246 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 247 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 248 | [ 'td', 'tr' ], | ||
| 249 | ); | ||
| 250 | 0 | $self->assert_display_does_not_contain([ 'sortby=description', 'description' ]); | |
| 251 | 0 | $self->assert_display_does_not_contain([ 'sortby=size', 'size' ]); | |
| 252 | } | ||
| 253 | |||
| 254 | sub test_search__default_orderby_and_sorting | ||
| 255 | 0 | ▶ | { |
|
Subroutine
test_search__default_orderby_and_sorting: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 256 | 0 | my $self = shift; | |
| 257 | 0 | $self->SUPER::test_search__default_orderby_and_sorting; | |
| 258 | |||
| 259 | # only displays most recent sorting | ||
| 260 | 0 | $self->assert_display_contains( | |
| 261 | [ 'tr', 'td' ], | ||
| 262 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 263 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 264 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 265 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 266 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 267 | [ 'td', 'tr' ], | ||
| 268 | ); | ||
| 269 | } | ||
| 270 | |||
| 271 | sub test_search__css_options | ||
| 272 | 0 | ▶ | { |
|
Subroutine
test_search__css_options: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 273 | 0 | my $self = shift; | |
| 274 | 0 | $self->{ws}->{-css_grid_class} = 'TestGridClass'; | |
| 275 | 0 | $self->{ws}->{-css_grid_cell_class} = 'TestGridCellClass'; | |
| 276 | 0 | $self->SUPER::test_search__basic; | |
| 277 | |||
| 278 | 0 | $self->assert_display_contains( | |
| 279 | [ 'table [^<>]*class="TestGridClass' ], | ||
| 280 | [ 'tr', 'td [^<>]*class="TestGridCellClass' ], | ||
| 281 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 282 | [ 'td [^<>]*class="TestGridCellClass' ], | ||
| 283 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 284 | [ 'td', 'tr', 'tr', 'td [^<>]*class="TestGridCellClass' ], | ||
| 285 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 286 | [ 'td [^<>]*class="TestGridCellClass' ], | ||
| 287 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 288 | [ 'td', 'tr' ], | ||
| 289 | ); | ||
| 290 | } | ||
| 291 | |||
| 292 | sub test_search__extra_attributes | ||
| 293 | 0 | ▶ | { |
|
Subroutine
test_search__extra_attributes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 294 | 0 | my $self = shift; | |
| 295 | 0 | $self->{ws}->{-extra_grid_cell_attributes} = { test_attr1 => 'foo', test_attr2 => 'bar' }; | |
| 296 | 0 | $self->SUPER::test_search__basic; | |
| 297 | |||
| 298 | 0 | $self->assert_display_contains( | |
| 299 | [ 'table' ], | ||
| 300 | [ 'tr', 'td [^<>]*test-attr(?:2="bar"|1="foo") [^<>]*test-attr(?:2="bar"|1="foo")[^<>]*><' ], | ||
| 301 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 302 | [ 'td [^<>]*test-attr(?:2="bar"|1="foo") [^<>]*test-attr(?:2="bar"|1="foo")[^<>]*><' ], | ||
| 303 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 304 | [ 'td', 'tr', 'tr', 'td [^<>]*test-attr(?:2="bar"|1="foo") [^<>]*test-attr(?:2="bar"|1="foo")[^<>]*><' ], | ||
| 305 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 306 | [ 'td [^<>]*test-attr(?:2="bar"|1="foo") [^<>]*test-attr(?:2="bar"|1="foo")[^<>]*><' ], | ||
| 307 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 308 | [ 'td', 'tr' ], | ||
| 309 | ); | ||
| 310 | } | ||
| 311 | |||
| 312 | sub test_search__extra_attributes_closure | ||
| 313 | 0 | ▶ | { |
|
Subroutine
test_search__extra_attributes_closure: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 314 | 0 | my $self = shift; | |
| 315 | 0 | ▶ | $self->{ws}->{-extra_grid_cell_attributes} = sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 316 | 0 | my ($obj, $row) = @_; | |
| 317 | 0 | my $col1 = $obj->{'header_columns'}->[0]; | |
| 318 | 0 | my $col2 = $obj->{'header_columns'}->[1]; | |
| 319 | 0 | return { 'attr_'.$col1 => $row->{$col1}, 'attr_'.$col2 => $row->{$col2} }; | |
| 320 | 0 | }; | |
| 321 | 0 | $self->SUPER::test_search__basic; | |
| 322 | |||
| 323 | 0 | $self->assert_display_contains( | |
| 324 | [ 'table' ], | ||
| 325 | [ 'tr', 'td [^<>]*attr-(?:widget-no="1"|name="clock_widget") [^<>]*attr-(?:widget-no="1"|name="clock_widget")[^<>]*><' ], | ||
| 326 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 327 | [ 'td [^<>]*attr-(?:widget-no="2"|name="calendar_widget") [^<>]*attr-(?:widget-no="2"|name="calendar_widget")[^<>]*><' ], | ||
| 328 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 329 | [ 'td', 'tr', 'tr', 'td [^<>]*attr-(?:widget-no="3"|name="silly_widget") [^<>]*attr-(?:widget-no="3"|name="silly_widget")[^<>]*><' ], | ||
| 330 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 331 | [ 'td [^<>]*attr-(?:widget-no="4"|name="gps_widget") [^<>]*attr-(?:widget-no="4"|name="gps_widget")[^<>]*><' ], | ||
| 332 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 333 | [ 'td', 'tr' ], | ||
| 334 | ); | ||
| 335 | } | ||
| 336 | |||
| 337 | sub test_browse_mode | ||
| 338 | 0 | ▶ | { |
|
Subroutine
test_browse_mode: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 339 | 0 | my $self = shift; | |
| 340 | 0 | $self->{ws}->{-browse_mode} = 1; | |
| 341 | 0 | $self->SUPER::test_search__basic; | |
| 342 | |||
| 343 | 0 | $self->assert_display_contains( | |
| 344 | [ 'tr', 'td' ], | ||
| 345 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 346 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 347 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 348 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 349 | [ 'td', 'tr' ], | ||
| 350 | ); | ||
| 351 | 0 | $self->assert_display_does_not_contain([ 'At first page', 'At last page' ]); | |
| 352 | 0 | $self->assert_display_does_not_contain([ 'Sort by', 'sortby_columns_popup' ]); | |
| 353 | 0 | $self->assert_display_does_not_contain([ 'Sort field' ]); | |
| 354 | 0 | $self->assert_display_does_not_contain([ 'sortby=widget_no', 'widget_no' ]); | |
| 355 | 0 | $self->assert_display_does_not_contain([ 'sortby=name', 'name', ]); | |
| 356 | } | ||
| 357 | |||
| 358 | sub test_browse_mode_with_paging | ||
| 359 | 0 | ▶ | { |
|
Subroutine
test_browse_mode_with_paging: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 360 | 0 | my $self = shift; | |
| 361 | 0 | my $ws = $self->{ws}; | |
| 362 | 0 | $ws->{-browse_mode} = 1; | |
| 363 | 0 | $ws->{-max_results_per_page} = 2; | |
| 364 | 0 | $ws->{-sql_table} = 'widgets'; | |
| 365 | 0 | $ws->{-sql_retrieve_columns} = [qw/widget_no name description size/]; | |
| 366 | |||
| 367 | 0 | $ws->search(); | |
| 368 | |||
| 369 | 0 | $self->assert_display_contains( | |
| 370 | [ 'At first page', '2', 'results displayed', '1 - 2', 'of', '4', 'Next >', 'Last >' ], | ||
| 371 | [ 'tr', 'td' ], | ||
| 372 | [ 1, 'clock_widget', 'A time keeper widget', 'small' ], | ||
| 373 | [ 2, 'calendar_widget', 'A date tracker widget', 'medium' ], | ||
| 374 | [ 'td', 'tr' ], | ||
| 375 | [ 'At first page', 'Next >', 'Last >' ], | ||
| 376 | ); | ||
| 377 | 0 | $self->assert_display_does_not_contain([ 'Sort by', 'sortby_columns_popup' ]); | |
| 378 | 0 | $self->assert_display_does_not_contain([ 'Sort field' ]); | |
| 379 | 0 | $self->assert_display_does_not_contain([ 'sortby=widget_no', 'widget_no' ]); | |
| 380 | 0 | $self->assert_display_does_not_contain([ 'sortby=name', 'name', ]); | |
| 381 | |||
| 382 | |||
| 383 | # reset search | ||
| 384 | 0 | $self->init_test_object(); | |
| 385 | 0 | $ws = $self->{ws}; | |
| 386 | 0 | $ws->{-browse_mode} = 1; | |
| 387 | 0 | $ws->{-max_results_per_page} = 2; | |
| 388 | 0 | $ws->{-sql_table} = 'widgets'; | |
| 389 | 0 | $ws->{-sql_retrieve_columns} = [qw/widget_no name description size/]; | |
| 390 | |||
| 391 | 0 | $ws->{q}->param('search_startat', 1); | |
| 392 | 0 | $ws->search(); | |
| 393 | |||
| 394 | 0 | $self->assert_display_contains( | |
| 395 | [ 'lt; First', 'lt; Previous', '2', 'results displayed', '3 - 4', 'of', '4', 'At last page' ], | ||
| 396 | [ 'tr', 'td' ], | ||
| 397 | [ 3, 'silly_widget', 'A goofball widget', 'unknown' ], | ||
| 398 | [ 4, 'gps_widget', 'A GPS widget', 'medium' ], | ||
| 399 | [ 'td', 'tr' ], | ||
| 400 | [ 'lt; First', 'lt; Previous', 'At last page' ], | ||
| 401 | ); | ||
| 402 | } | ||
| 403 | |||
| 404 | |||
| 405 | 1 | 1; | |