| 1 | package CGI::Widget::DBI::TEST::Browse; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use CGI::Widget::DBI::TEST::TestCase; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | use base qw/ CGI::Widget::DBI::TEST::TestCase /; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | ▶ | use CGI::Widget::DBI::Browse; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | sub init_test_object | ||
| 10 | 0 | ▶ | { |
|
Subroutine
init_test_object: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 11 | 0 | my $self = shift; | |
| 12 | 0 | my $q = CGI->new; | |
| 13 | $self->{_test_obj} = $self->{wb} = CGI::Widget::DBI::Browse->new( | ||
| 14 | q => $q, -dbh => $self->{-dbh}, | ||
| 15 | -sql_table => 'cities left outer join cities_join using (city_no)', | ||
| 16 | -sql_retrieve_columns => [ | ||
| 17 | qw/city_no name description population cities.state_or_province/, | ||
| 18 | 'coalesce(cities.country, cities.state_or_province) as nation' | ||
| 19 | ], | ||
| 20 | -cache_categories => $ENV{CACHE_CATEGORIES}, | ||
| 21 | 0 | _DEBUG => 0, | |
| 22 | ); | ||
| 23 | 0 | $self->{wb}->{-category_columns} = [ qw/continent nation state_or_province/ ]; | |
| 24 | 0 | $self->{wb}->{-category_sql_retrieve_columns} = { state_or_province => [qw/nation/] }; | |
| 25 | $self->{wb}->{-category_column_closures} = { | ||
| 26 | 0 | ▶ | state_or_province => sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 27 | 0 | my ($obj, $row) = @_; | |
| 28 | 0 | return $row->{'state_or_province'}.', '.$row->{'nation'}; | |
| 29 | }, | ||
| 30 | 0 | }; | |
| 31 | } | ||
| 32 | |||
| 33 | sub tear_down | ||
| 34 | 0 | ▶ | { |
|
Subroutine
tear_down: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 35 | 0 | my $self = shift; | |
| 36 | 0 | $self->{-dbh}->do('DROP TABLE IF EXISTS browse_widget_category_cache'); | |
| 37 | 0 | $self->SUPER::tear_down(); | |
| 38 | } | ||
| 39 | |||
| 40 | 0 | ▶ | sub _db_schemas { |
|
Subroutine
_db_schemas: not called CC=1 SCAR=6.9
| |||
| 41 | 0 | my @schemas = (<<'DDL1', <<'DDL2'); | |
| 42 | create temporary table cities ( | ||
| 43 | city_no integer not null primary key auto_increment, | ||
| 44 | continent varchar(16), | ||
| 45 | country varchar(24), | ||
| 46 | state_or_province varchar(24), | ||
| 47 | name varchar(32), | ||
| 48 | description text, | ||
| 49 | population integer, | ||
| 50 | |||
| 51 | index continent (continent), | ||
| 52 | index country (country), | ||
| 53 | index state_or_province (state_or_province) | ||
| 54 | ) | ||
| 55 | DDL1 | ||
| 56 | create temporary table cities_join ( | ||
| 57 | city_no int, | ||
| 58 | state_or_province varchar(24) | ||
| 59 | ) | ||
| 60 | DDL2 | ||
| 61 | # second table is an empty table just to test two columns with same name | ||
| 62 | 0 | return @schemas; | |
| 63 | } | ||
| 64 | |||
| 65 | 0 | ▶ | sub _insert_test_data { |
|
Subroutine
_insert_test_data: not called CC=1 SCAR=6.9
| |||
| 66 | 0 | my ($self) = @_; | |
| 67 | 0 | my $sth1 = $self->{-dbh}->prepare_cached(q{ | |
| 68 | insert into | ||
| 69 | cities (city_no, continent, country, state_or_province, name, description, population) | ||
| 70 | values (?, ?, ?, ?, ?, ?, ?) | ||
| 71 | }); | ||
| 72 | map { | ||
| 73 | 0 | $sth1->execute(@$_); | |
| 74 | } ( | ||
| 75 | [ 1, 'Africa', 'Madagascar', 'Antananarivo', 'Antananarivo', 'Capital of Madagascar', 1_403_449 ], | ||
| 76 | [ 2, 'Africa', undef, undef, 'Sahara Desert', 'Largest desert in the world', 13 ], | ||
| 77 | [ 3, 'Asia', 'Japan', 'Kanto', 'Tokyo', 'Largest city in the world', 34_450_000 ], | ||
| 78 | [ 4, 'Asia', 'India', 'Maharashtra', 'Mumbai', 'Largest city in India, capital of western state of Maharashtra', 19_380_000 ], | ||
| 79 | [ 5, 'Asia', 'Thailand', 'Bangkok', 'Bangkok', 'City with the longest full name in the world', 8_190_000 ], | ||
| 80 | [ 6, 'Australia', 'Australia', 'Victoria', 'Melbourne', 'State capital of Victoria, second largest city in Australia', 3_340_000 ], | ||
| 81 | [ 7, 'Europe', 'Norway', 'Oslo', 'Oslo', 'Capital of Norway', 548_617 ], | ||
| 82 | [ 8, 'Europe', 'Denmark', 'Oresund', 'Copenhagen', 'Second most livable city in the world', 1_835_467 ], | ||
| 83 | [ 9, 'Europe', 'Italy', 'Lombardy', 'Milan', 'Fashion capital of the world', 4_950_000 ], | ||
| 84 | [ 10, 'North America', 'Canada', 'British Columbia', 'Vancouver', 'Beautiful B.C.', 2_249_725 ], | ||
| 85 | [ 11, 'North America', 'United States', 'New York', 'New York', 'Financial capital of the world', 20_420_000 ], | ||
| 86 | [ 12, 'North America', 'United States', 'New York', 'Ithaca', 'Ithaca is Gorges', 100_018 ], | ||
| 87 | [ 13, 'North America', 'United States', 'Oregon', 'Portland', 'Microbrew capital of the world', 1_583_138 ], | ||
| 88 | [ 14, 'South America', 'Brazil', 'Sao Paulo', 'Sao Paulo', 'Most populous city in South America', 18_130_000 ], | ||
| 89 | [ 15, 'South America', 'Argentina', '(federal)', 'Buenos Aires', 'Capital of Argentina', 13_460_000 ], | ||
| 90 | ); | ||
| 91 | |||
| 92 | 0 | $self->assert_table_contents_equal( | |
| 93 | 'cities', [qw/city_no continent country state_or_province name description population/], | ||
| 94 | [ | ||
| 95 | [ 1, 'Africa', 'Madagascar', 'Antananarivo', 'Antananarivo', 'Capital of Madagascar', 1_403_449 ], | ||
| 96 | [ 2, 'Africa', undef, undef, 'Sahara Desert', 'Largest desert in the world', 13 ], | ||
| 97 | [ 3, 'Asia', 'Japan', 'Kanto', 'Tokyo', 'Largest city in the world', 34_450_000 ], | ||
| 98 | [ 4, 'Asia', 'India', 'Maharashtra', 'Mumbai', 'Largest city in India, capital of western state of Maharashtra', 19_380_000 ], | ||
| 99 | [ 5, 'Asia', 'Thailand', 'Bangkok', 'Bangkok', 'City with the longest full name in the world', 8_190_000 ], | ||
| 100 | [ 6, 'Australia', 'Australia', 'Victoria', 'Melbourne', 'State capital of Victoria, second largest city in Australia', 3_340_000 ], | ||
| 101 | [ 7, 'Europe', 'Norway', 'Oslo', 'Oslo', 'Capital of Norway', 548_617 ], | ||
| 102 | [ 8, 'Europe', 'Denmark', 'Oresund', 'Copenhagen', 'Second most livable city in the world', 1_835_467 ], | ||
| 103 | [ 9, 'Europe', 'Italy', 'Lombardy', 'Milan', 'Fashion capital of the world', 4_950_000 ], | ||
| 104 | [ 10, 'North America', 'Canada', 'British Columbia', 'Vancouver', 'Beautiful B.C.', 2_249_725 ], | ||
| 105 | [ 11, 'North America', 'United States', 'New York', 'New York', 'Financial capital of the world', 20_420_000 ], | ||
| 106 | [ 12, 'North America', 'United States', 'New York', 'Ithaca', 'Ithaca is Gorges', 100_018 ], | ||
| 107 | [ 13, 'North America', 'United States', 'Oregon', 'Portland', 'Microbrew capital of the world', 1_583_138 ], | ||
| 108 | [ 14, 'South America', 'Brazil', 'Sao Paulo', 'Sao Paulo', 'Most populous city in South America', 18_130_000 ], | ||
| 109 | [ 15, 'South America', 'Argentina', '(federal)', 'Buenos Aires', 'Capital of Argentina', 13_460_000 ], | ||
| 110 | ], | ||
| 111 | ); | ||
| 112 | } | ||
| 113 | |||
| 114 | |||
| 115 | sub test_display__top_level | ||
| 116 | 0 | ▶ | { |
|
Subroutine
test_display__top_level: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 117 | 0 | my $self = shift; | |
| 118 | |||
| 119 | # TODO: make the test for id="categoryNavLink" independent of attribute order in <a> tag | ||
| 120 | 0 | $self->assert_display_contains( | |
| 121 | [ 'tr', 'td' ], | ||
| 122 | |||
| 123 | [ 'continent=Africa[^<>]+id="categoryNavLink-Africa".*', 'Africa' ], | ||
| 124 | [ 'continent=Asia[^<>]+id="categoryNavLink-Asia".*', 'Asia' ], | ||
| 125 | [ 'continent=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 126 | [ 'continent=Europe[^<>]+id="categoryNavLink-Europe".*', 'Europe' ], | ||
| 127 | |||
| 128 | [ 'td', 'tr', 'tr', 'td' ], | ||
| 129 | |||
| 130 | [ 'continent=North%20America[^<>]+id="categoryNavLink-North America".*', 'North America' ], | ||
| 131 | [ 'continent=South%20America[^<>]+id="categoryNavLink-South America".*', 'South America' ], | ||
| 132 | |||
| 133 | [ 'td', 'tr' ], | ||
| 134 | ); | ||
| 135 | 0 | $self->assert_equals('', $self->{wb}->category_title()); | |
| 136 | |||
| 137 | 0 | $self->assert_display_does_not_contain([ 'input type="hidden' ]); | |
| 138 | 0 | $self->assert_display_does_not_contain([ 'At first page', 'At last page' ]); | |
| 139 | 0 | $self->assert_display_does_not_contain([ 'Sort by', 'sortby_columns_popup' ]); | |
| 140 | 0 | $self->assert_display_does_not_contain([ 'Sort field' ]); | |
| 141 | |||
| 142 | 0 | $self->assert_equals('continent', $self->{wb}->is_browsing()); | |
| 143 | 0 | $self->assert(! $self->{wb}->parent_category_column()); | |
| 144 | 0 | $self->assert_deep_equals([], [$self->{wb}->ancestor_category_columns()]); | |
| 145 | } | ||
| 146 | |||
| 147 | sub test_display__top_level__works_with_stray_sortby_param | ||
| 148 | 0 | ▶ | { |
|
Subroutine
test_display__top_level__works_with_stray_sortby_param: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 149 | 0 | my $self = shift; | |
| 150 | 0 | $self->{wb}->{q}->param('sortby', 'nation'); | |
| 151 | 0 | $self->test_display__top_level(); | |
| 152 | } | ||
| 153 | |||
| 154 | sub test_display__top_level__uses_href_extra_vars_for_category_nav_links | ||
| 155 | 0 | ▶ | { |
|
Subroutine
test_display__top_level__uses_href_extra_vars_for_category_nav_links: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 156 | 0 | my $self = shift; | |
| 157 | 0 | $self->{wb}->{q}->param('href_testvar', 'foo'); | |
| 158 | 0 | $self->{wb}->{ws}->{-href_extra_vars} = { href_testvar => undef }; | |
| 159 | |||
| 160 | 0 | $self->test_display__top_level(); | |
| 161 | |||
| 162 | 0 | $self->assert_display_contains( | |
| 163 | [ 'continent=Africa\S*&href_testvar=foo"[^<>]+id="categoryNavLink-Africa".*', 'Africa' ], | ||
| 164 | [ 'continent=Asia\S*&href_testvar=foo"[^<>]+id="categoryNavLink-Asia".*', 'Asia' ], | ||
| 165 | [ 'continent=Australia\S*&href_testvar=foo"[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 166 | [ 'continent=Europe\S*&href_testvar=foo"[^<>]+id="categoryNavLink-Europe".*', 'Europe' ], | ||
| 167 | [ 'continent=North%20America\S*&href_testvar=foo"[^<>]+id="categoryNavLink-North America".*', 'North America' ], | ||
| 168 | [ 'continent=South%20America\S*&href_testvar=foo"[^<>]+id="categoryNavLink-South America".*', 'South America' ], | ||
| 169 | ); | ||
| 170 | } | ||
| 171 | |||
| 172 | sub test_display__top_level__creates_category_cache_table | ||
| 173 | 0 | ▶ | { |
|
Subroutine
test_display__top_level__creates_category_cache_table: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 174 | 0 | my $self = shift; | |
| 175 | 0 | local $ENV{CACHE_CATEGORIES} = 1; | |
| 176 | 0 | $self->init_test_object(); | |
| 177 | |||
| 178 | 0 | $self->test_display__top_level(); | |
| 179 | |||
| 180 | 0 | $self->assert_table_contents_equal( | |
| 181 | 'browse_widget_category_cache', [qw/category_column category_value child_value/], | ||
| 182 | [ | ||
| 183 | [ undef, undef, 'Africa' ], | ||
| 184 | [ undef, undef, 'Asia' ], | ||
| 185 | [ undef, undef, 'Australia' ], | ||
| 186 | [ undef, undef, 'Europe' ], | ||
| 187 | [ undef, undef, 'North America' ], | ||
| 188 | [ undef, undef, 'South America' ], | ||
| 189 | ], | ||
| 190 | ); | ||
| 191 | |||
| 192 | # test again to verify cached results show up | ||
| 193 | 0 | $self->init_test_object(); | |
| 194 | 0 | $self->test_display__top_level(); | |
| 195 | } | ||
| 196 | |||
| 197 | sub test_display__second_level | ||
| 198 | 0 | ▶ | { |
|
Subroutine
test_display__second_level: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 199 | 0 | my $self = shift; | |
| 200 | 0 | my $wb = $self->{wb}; | |
| 201 | |||
| 202 | 0 | $wb->{q}->param('continent', 'Africa'); | |
| 203 | |||
| 204 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 205 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 206 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 207 | 0 | $self->assert_display_contains( | |
| 208 | [ 'continent=Africa&_browse_skip_to_results_=1"[^<>]+id="skipToResultsLink', | ||
| 209 | "Show all items in this category" ], | ||
| 210 | [ 'input type="hidden" name="continent" value="Africa' ], | ||
| 211 | [ 'tr', 'td' ], | ||
| 212 | [ 'continent=Africa&nation=Madagascar[^<>]+id="categoryNavLink-Madagascar".*', 'Madagascar' ], | ||
| 213 | [ 'td', 'tr' ], | ||
| 214 | ); | ||
| 215 | # test does not contain NULL category | ||
| 216 | 0 | $self->assert_display_does_not_contain([ 'a href="\?continent=Africa&nation=" id="categoryNavLink-Africa"></a' ]); | |
| 217 | 0 | $self->assert_equals('Africa', $wb->category_title()); | |
| 218 | |||
| 219 | 0 | $self->init_test_object(); | |
| 220 | 0 | $wb = $self->{wb}; | |
| 221 | |||
| 222 | 0 | $wb->{q}->param('continent', 'Asia'); | |
| 223 | |||
| 224 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 225 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 226 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 227 | 0 | $self->assert_display_contains( | |
| 228 | [ 'input type="hidden" name="continent" value="Asia' ], | ||
| 229 | [ 'tr', 'td' ], | ||
| 230 | [ 'continent=Asia&nation=India[^<>]+id="categoryNavLink-India".*', 'India' ], | ||
| 231 | [ 'continent=Asia&nation=Japan[^<>]+id="categoryNavLink-Japan".*', 'Japan' ], | ||
| 232 | [ 'continent=Asia&nation=Thailand[^<>]+id="categoryNavLink-Thailand".*', 'Thailand' ], | ||
| 233 | [ 'td', 'tr' ], | ||
| 234 | ); | ||
| 235 | 0 | $self->assert_equals('Asia', $wb->category_title()); | |
| 236 | |||
| 237 | 0 | $self->init_test_object(); | |
| 238 | 0 | $wb = $self->{wb}; | |
| 239 | |||
| 240 | 0 | $wb->{q}->param('continent', 'Australia'); | |
| 241 | |||
| 242 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 243 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 244 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 245 | 0 | $self->assert_display_contains( | |
| 246 | [ 'input type="hidden" name="continent" value="Australia' ], | ||
| 247 | [ 'tr', 'td' ], | ||
| 248 | [ 'continent=Australia&nation=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 249 | [ 'td', 'tr' ], | ||
| 250 | ); | ||
| 251 | 0 | $self->assert_equals('Australia', $wb->category_title()); | |
| 252 | |||
| 253 | 0 | $self->init_test_object(); | |
| 254 | 0 | $wb = $self->{wb}; | |
| 255 | |||
| 256 | 0 | $wb->{q}->param('continent', 'Europe'); | |
| 257 | |||
| 258 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 259 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 260 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 261 | 0 | $self->assert_display_contains( | |
| 262 | [ 'input type="hidden" name="continent" value="Europe' ], | ||
| 263 | [ 'tr', 'td' ], | ||
| 264 | [ 'continent=Europe&nation=Denmark[^<>]+id="categoryNavLink-Denmark".*', 'Denmark' ], | ||
| 265 | [ 'continent=Europe&nation=Italy[^<>]+id="categoryNavLink-Italy".*', 'Italy' ], | ||
| 266 | [ 'continent=Europe&nation=Norway[^<>]+id="categoryNavLink-Norway".*', 'Norway' ], | ||
| 267 | [ 'td', 'tr' ], | ||
| 268 | ); | ||
| 269 | 0 | $self->assert_equals('Europe', $wb->category_title()); | |
| 270 | |||
| 271 | 0 | $self->init_test_object(); | |
| 272 | 0 | $wb = $self->{wb}; | |
| 273 | |||
| 274 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 275 | |||
| 276 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 277 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 278 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 279 | 0 | $self->assert_display_contains( | |
| 280 | [ 'input type="hidden" name="continent" value="North America' ], | ||
| 281 | [ 'tr', 'td' ], | ||
| 282 | [ 'continent=North%20America&nation=Canada[^<>]+id="categoryNavLink-Canada".*', 'Canada' ], | ||
| 283 | [ 'continent=North%20America&nation=United%20States[^<>]+id="categoryNavLink-United States".*', 'United States' ], | ||
| 284 | [ 'td', 'tr' ], | ||
| 285 | ); | ||
| 286 | 0 | $self->assert_equals('North America', $wb->category_title()); | |
| 287 | |||
| 288 | 0 | $self->init_test_object(); | |
| 289 | 0 | $wb = $self->{wb}; | |
| 290 | |||
| 291 | 0 | $wb->{q}->param('continent', 'South America'); | |
| 292 | |||
| 293 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 294 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 295 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 296 | 0 | $self->assert_display_contains( | |
| 297 | [ 'input type="hidden" name="continent" value="South America' ], | ||
| 298 | [ 'tr', 'td' ], | ||
| 299 | [ 'continent=South%20America&nation=Argentina[^<>]+id="categoryNavLink-Argentina".*', 'Argentina' ], | ||
| 300 | [ 'continent=South%20America&nation=Brazil[^<>]+id="categoryNavLink-Brazil".*', 'Brazil' ], | ||
| 301 | [ 'td', 'tr' ], | ||
| 302 | ); | ||
| 303 | 0 | $self->assert_equals('South America', $wb->category_title()); | |
| 304 | |||
| 305 | 0 | $self->assert_display_does_not_contain([ 'At first page', 'At last page' ]); | |
| 306 | 0 | $self->assert_display_does_not_contain([ 'Sort by', 'sortby_columns_popup' ]); | |
| 307 | 0 | $self->assert_display_does_not_contain([ 'Sort field' ]); | |
| 308 | } | ||
| 309 | |||
| 310 | sub test_display__second_level__uses_href_extra_vars_for_category_nav_links | ||
| 311 | 0 | ▶ | { |
|
Subroutine
test_display__second_level__uses_href_extra_vars_for_category_nav_links: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 312 | 0 | my $self = shift; | |
| 313 | 0 | $self->{wb}->{q}->param('href_testvar', 'foo'); | |
| 314 | 0 | $self->{wb}->{ws}->{-href_extra_vars} = { href_testvar => undef }; | |
| 315 | |||
| 316 | 0 | $self->{wb}->{q}->param('continent', 'South America'); | |
| 317 | |||
| 318 | 0 | $self->assert_display_contains( | |
| 319 | [ 'continent=South%20America&nation=Argentina\S*&href_testvar=foo"[^<>]+id="categoryNavLink-Argentina".*', 'Argentina' ], | ||
| 320 | [ 'continent=South%20America&nation=Brazil\S*&href_testvar=foo"[^<>]+id="categoryNavLink-Brazil".*', 'Brazil' ], | ||
| 321 | ); | ||
| 322 | 0 | $self->assert_display_does_not_contain( | |
| 323 | [ 'continent=South%20America\S*continent=South%20America[^<>]+id="categoryNavLink-' ], | ||
| 324 | ); | ||
| 325 | 0 | $self->assert_display_does_not_contain( | |
| 326 | [ 'nation=Brazil\S*nation=Brazil[^<>]+id="categoryNavLink-' ], | ||
| 327 | ); | ||
| 328 | } | ||
| 329 | |||
| 330 | sub test_display__second_level__creates_category_cache_table | ||
| 331 | 0 | ▶ | { |
|
Subroutine
test_display__second_level__creates_category_cache_table: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 332 | 0 | my $self = shift; | |
| 333 | 0 | local $ENV{CACHE_CATEGORIES} = 1; | |
| 334 | 0 | $self->init_test_object(); | |
| 335 | |||
| 336 | 0 | $self->test_display__second_level(); | |
| 337 | |||
| 338 | 0 | $self->assert_table_contents_equal( | |
| 339 | 'browse_widget_category_cache', [qw/category_column category_value child_value/], | ||
| 340 | [ | ||
| 341 | [ 'continent', 'Africa', '', ], # coalesced to '' | ||
| 342 | [ 'continent', 'Africa', 'Madagascar', ], | ||
| 343 | [ 'continent', 'Asia', 'India', ], | ||
| 344 | [ 'continent', 'Asia', 'Japan', ], | ||
| 345 | [ 'continent', 'Asia', 'Thailand', ], | ||
| 346 | [ 'continent', 'Australia', 'Australia', ], | ||
| 347 | [ 'continent', 'Europe', 'Denmark', ], | ||
| 348 | [ 'continent', 'Europe', 'Italy', ], | ||
| 349 | [ 'continent', 'Europe', 'Norway', ], | ||
| 350 | [ 'continent', 'North America', 'Canada', ], | ||
| 351 | [ 'continent', 'North America', 'United States', ], | ||
| 352 | [ 'continent', 'South America', 'Argentina', ], | ||
| 353 | [ 'continent', 'South America', 'Brazil', ], | ||
| 354 | ], | ||
| 355 | ); | ||
| 356 | |||
| 357 | # test again to verify cached results show up | ||
| 358 | 0 | $self->init_test_object(); | |
| 359 | 0 | $self->test_display__second_level(); | |
| 360 | } | ||
| 361 | |||
| 362 | sub test_display__third_level | ||
| 363 | 0 | ▶ | { |
|
Subroutine
test_display__third_level: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 364 | 0 | my $self = shift; | |
| 365 | 0 | my $wb = $self->{wb}; | |
| 366 | |||
| 367 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 368 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 369 | |||
| 370 | 0 | $self->assert_equals('state_or_province', $wb->is_browsing()); | |
| 371 | 0 | $self->assert_equals('nation', $wb->parent_category_column()); | |
| 372 | 0 | $self->assert_deep_equals([qw/continent nation/], [$self->{wb}->ancestor_category_columns()]); | |
| 373 | 0 | $self->assert_display_contains( | |
| 374 | [ 'input type="hidden" name="continent" value="North America' ], | ||
| 375 | [ 'input type="hidden" name="nation" value="United States' ], | ||
| 376 | [ 'tr', 'td' ], | ||
| 377 | [ 'continent=North%20America&nation=United%20States&state_or_province=New%20York[^<>]+id="categoryNavLink-New York".*', 'New York, United States' ], | ||
| 378 | [ 'continent=North%20America&nation=United%20States&state_or_province=Oregon[^<>]+id="categoryNavLink-Oregon".*', 'Oregon, United States' ], | ||
| 379 | [ 'td', 'tr' ], | ||
| 380 | ); | ||
| 381 | # test New York not listed twice | ||
| 382 | 0 | $self->assert_display_does_not_contain( | |
| 383 | [ 'state_or_province=New%20York', 'New York' ], | ||
| 384 | [ 'New York' ], | ||
| 385 | [ 'state_or_province=New%20York', 'New York' ], | ||
| 386 | [ 'New York' ], | ||
| 387 | ); | ||
| 388 | 0 | $self->assert_equals('North America > United States', $wb->category_title()); | |
| 389 | |||
| 390 | 0 | $self->init_test_object(); | |
| 391 | 0 | $wb = $self->{wb}; | |
| 392 | |||
| 393 | 0 | $wb->{q}->param('continent', 'Asia'); | |
| 394 | 0 | $wb->{q}->param('nation', 'India'); | |
| 395 | |||
| 396 | 0 | $self->assert_equals('state_or_province', $wb->is_browsing()); | |
| 397 | 0 | $self->assert_equals('nation', $wb->parent_category_column()); | |
| 398 | 0 | $self->assert_deep_equals([qw/continent nation/], [$self->{wb}->ancestor_category_columns()]); | |
| 399 | 0 | $self->assert_display_contains( | |
| 400 | [ 'input type="hidden" name="continent" value="Asia' ], | ||
| 401 | [ 'input type="hidden" name="nation" value="India' ], | ||
| 402 | [ 'tr', 'td' ], | ||
| 403 | [ 'continent=Asia&nation=India&state_or_province=Maharashtra[^<>]+id="categoryNavLink-Maharashtra".*', 'Maharashtra, India' ], | ||
| 404 | [ 'td', 'tr' ], | ||
| 405 | ); | ||
| 406 | 0 | $self->assert_equals('Asia > India', $wb->category_title()); | |
| 407 | |||
| 408 | 0 | $self->init_test_object(); | |
| 409 | 0 | $wb = $self->{wb}; | |
| 410 | |||
| 411 | 0 | $wb->{q}->param('continent', 'Asia'); | |
| 412 | 0 | $wb->{q}->param('nation', 'Japan'); | |
| 413 | |||
| 414 | 0 | $self->assert_equals('state_or_province', $wb->is_browsing()); | |
| 415 | 0 | $self->assert_equals('nation', $wb->parent_category_column()); | |
| 416 | 0 | $self->assert_deep_equals([qw/continent nation/], [$self->{wb}->ancestor_category_columns()]); | |
| 417 | 0 | $self->assert_display_contains( | |
| 418 | [ 'input type="hidden" name="continent" value="Asia' ], | ||
| 419 | [ 'input type="hidden" name="nation" value="Japan' ], | ||
| 420 | [ 'tr', 'td' ], | ||
| 421 | [ 'continent=Asia&nation=Japan&state_or_province=Kanto[^<>]+id="categoryNavLink-Kanto".*', 'Kanto, Japan' ], | ||
| 422 | [ 'td', 'tr' ], | ||
| 423 | ); | ||
| 424 | 0 | $self->assert_equals('Asia > Japan', $wb->category_title()); | |
| 425 | |||
| 426 | 0 | $self->assert_display_does_not_contain([ 'At first page', 'At last page' ]); | |
| 427 | 0 | $self->assert_display_does_not_contain([ 'Sort by', 'sortby_columns_popup' ]); | |
| 428 | 0 | $self->assert_display_does_not_contain([ 'Sort field' ]); | |
| 429 | } | ||
| 430 | |||
| 431 | sub test_display__third_level__uses_href_extra_vars_for_category_nav_links | ||
| 432 | 0 | ▶ | { |
|
Subroutine
test_display__third_level__uses_href_extra_vars_for_category_nav_links: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 433 | 0 | my $self = shift; | |
| 434 | 0 | $self->{wb}->{q}->param('href_testvar', 'foo'); | |
| 435 | 0 | $self->{wb}->{ws}->{-href_extra_vars} = { href_testvar => undef }; | |
| 436 | |||
| 437 | 0 | $self->{wb}->{q}->param('continent', 'Asia'); | |
| 438 | 0 | $self->{wb}->{q}->param('nation', 'Japan'); | |
| 439 | |||
| 440 | 0 | $self->assert_display_contains( | |
| 441 | [ 'continent=Asia&nation=Japan&state_or_province=Kanto\S*&href_testvar=foo"[^<>]+id="categoryNavLink-Kanto".*', 'Kanto, Japan' ], | ||
| 442 | ); | ||
| 443 | 0 | $self->assert_display_does_not_contain( | |
| 444 | [ 'continent=Asia\S*continent=Asia[^<>]+id="categoryNavLink-' ], | ||
| 445 | ); | ||
| 446 | 0 | $self->assert_display_does_not_contain( | |
| 447 | [ 'nation=Japan\S*nation=Japan[^<>]+id="categoryNavLink-' ], | ||
| 448 | ); | ||
| 449 | 0 | $self->assert_display_does_not_contain( | |
| 450 | [ 'state_or_province=Kanto\S*state_or_province=Kanto[^<>]+id="categoryNavLink-' ], | ||
| 451 | ); | ||
| 452 | } | ||
| 453 | |||
| 454 | sub test_display__third_level__creates_category_cache_table | ||
| 455 | 0 | ▶ | { |
|
Subroutine
test_display__third_level__creates_category_cache_table: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 456 | 0 | my $self = shift; | |
| 457 | 0 | local $ENV{CACHE_CATEGORIES} = 1; | |
| 458 | 0 | $self->init_test_object(); | |
| 459 | |||
| 460 | 0 | $self->test_display__third_level(); | |
| 461 | |||
| 462 | 0 | $self->assert_table_contents_equal( | |
| 463 | 'browse_widget_category_cache', [qw/category_column category_value child_value/], | ||
| 464 | [ | ||
| 465 | [ 'nation', 'India', 'Maharashtra', ], | ||
| 466 | [ 'nation', 'Japan', 'Kanto', ], | ||
| 467 | [ 'nation', 'United States', 'New York', ], | ||
| 468 | [ 'nation', 'United States', 'Oregon', ], | ||
| 469 | ], | ||
| 470 | ); | ||
| 471 | |||
| 472 | # test again to verify cached results show up | ||
| 473 | 0 | $self->init_test_object(); | |
| 474 | 0 | $self->test_display__third_level(); | |
| 475 | } | ||
| 476 | |||
| 477 | sub test_display__paging_category_navigation | ||
| 478 | 0 | ▶ | { |
|
Subroutine
test_display__paging_category_navigation: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 479 | 0 | my $self = shift; | |
| 480 | 0 | my $wb = $self->{wb}; | |
| 481 | 0 | $wb->{-max_category_results_per_page} = 3; | |
| 482 | |||
| 483 | # multi-page browse of categories: that paging links do show up, and | ||
| 484 | # that correct total num_results shows | ||
| 485 | 0 | $self->assert_display_contains( | |
| 486 | [ 'At first page', '3', 'results displayed', '1 - 3', 'of', '6', 'search_startat=1', 'Next >' ], | ||
| 487 | [ 'tr', 'td' ], | ||
| 488 | [ 'continent=Africa[^<>]+id="categoryNavLink-Africa".*', 'Africa' ], | ||
| 489 | [ 'continent=Asia[^<>]+id="categoryNavLink-Asia".*', 'Asia' ], | ||
| 490 | [ 'continent=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 491 | [ 'td', 'tr' ], | ||
| 492 | [ 'At first page', 'search_startat=1', 'Next >' ], | ||
| 493 | ); | ||
| 494 | 0 | $self->assert_display_does_not_contain([ 'continent=Europe[^<>]+id="categoryNavLink-Europe".*', 'Europe' ]); | |
| 495 | 0 | $self->assert_display_does_not_contain([ 'continent=North%20America[^<>]+id="categoryNavLink-North America".*', 'North America' ]); | |
| 496 | 0 | $self->assert_display_does_not_contain([ 'continent=South%20America[^<>]+id="categoryNavLink-South America".*', 'South America' ]); | |
| 497 | 0 | $self->assert_display_does_not_contain([ 'Sort by', 'sortby_columns_popup' ]); | |
| 498 | 0 | $self->assert_display_does_not_contain([ 'Sort field' ]); | |
| 499 | |||
| 500 | 0 | $self->init_test_object(); | |
| 501 | 0 | $wb = $self->{wb}; | |
| 502 | |||
| 503 | 0 | $wb->{-max_category_results_per_page} = 3; | |
| 504 | 0 | $wb->{q}->param('search_startat', 1); | |
| 505 | |||
| 506 | 0 | $self->assert_display_contains( | |
| 507 | [ 'search_startat=0', 'lt; Previous', '3', 'results displayed', '4 - 6', 'of', '6', 'At last page', ], | ||
| 508 | [ 'tr', 'td' ], | ||
| 509 | [ 'continent=Europe[^<>]+id="categoryNavLink-Europe".*', 'Europe' ], | ||
| 510 | [ 'continent=North%20America[^<>]+id="categoryNavLink-North America".*', 'North America' ], | ||
| 511 | [ 'continent=South%20America[^<>]+id="categoryNavLink-South America".*', 'South America' ], | ||
| 512 | [ 'td', 'tr' ], | ||
| 513 | [ 'search_startat=0', 'lt; Previous', 'At last page', ], | ||
| 514 | ); | ||
| 515 | 0 | $self->assert_display_does_not_contain([ 'continent=Africa[^<>]+id="categoryNavLink-Africa".*', 'Africa' ]); | |
| 516 | 0 | $self->assert_display_does_not_contain([ 'continent=Asia[^<>]+id="categoryNavLink-Asia".*', 'Asia' ]); | |
| 517 | 0 | $self->assert_display_does_not_contain([ 'continent=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ]); | |
| 518 | |||
| 519 | # test 'Top' breadcrumb does not get repeatedly prepended to -optional_header | ||
| 520 | 0 | $self->assert_display_does_not_contain([ 'id="breadcrumbNavLink-Top', 'Top', 'id="breadcrumbNavLink-Top', 'Top' ]); | |
| 521 | } | ||
| 522 | |||
| 523 | sub test_display__skip_to_results_from_category_navigation | ||
| 524 | 0 | ▶ | { |
|
Subroutine
test_display__skip_to_results_from_category_navigation: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 525 | 0 | my $self = shift; | |
| 526 | 0 | my $wb = $self->{wb}; | |
| 527 | |||
| 528 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 529 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 530 | 0 | $wb->{-skip_to_results} = 1; | |
| 531 | |||
| 532 | 0 | $self->assert(! $wb->is_browsing()); | |
| 533 | 0 | $self->assert_equals('state_or_province', $wb->parent_category_column()); | |
| 534 | 0 | $self->assert_deep_equals([qw/continent nation state_or_province/], [$self->{wb}->ancestor_category_columns()]); | |
| 535 | 0 | $self->assert_display_contains( | |
| 536 | [ 'input type="hidden" name="continent" value="North America' ], | ||
| 537 | [ 'input type="hidden" name="nation" value="United States' ], | ||
| 538 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 539 | [ 'sortby=city_no', 'continent=North%20America', 'city_no' ], | ||
| 540 | [ 'sortby=name', 'nation=United%20States', 'name' ], | ||
| 541 | [ 'sortby=population', 'continent=North%20America', 'population' ], | ||
| 542 | [ 'At first page', 'At last page' ], | ||
| 543 | [ 'tr', 'td' ], | ||
| 544 | [ 'New York', 'Financial capital of the world', 20_420_000 ], | ||
| 545 | [ 'Ithaca', 'Ithaca is Gorges', 100_018 ], | ||
| 546 | [ 'Portland', 'Microbrew capital of the world', 1_583_138 ], | ||
| 547 | [ 'td', 'tr' ], | ||
| 548 | [ 'At first page', 'At last page' ], | ||
| 549 | ); | ||
| 550 | 0 | $self->assert_equals('North America > United States', $wb->category_title()); | |
| 551 | |||
| 552 | 0 | $self->assert_display_does_not_contain( | |
| 553 | [ 'continent=North%20America&nation=United%20States&state_or_province=New%20York[^<>]+id="categoryNavLink-New York".*', 'New York' ], | ||
| 554 | ); | ||
| 555 | 0 | $self->assert_display_does_not_contain( | |
| 556 | [ 'continent=North%20America&nation=United%20States&state_or_province=Oregon[^<>]+id="categoryNavLink-Oregon".*', 'Oregon' ], | ||
| 557 | ); | ||
| 558 | 0 | $self->assert_display_does_not_contain([ 'categoryNavLink-' ]); | |
| 559 | |||
| 560 | 0 | $self->init_test_object(); | |
| 561 | 0 | $wb = $self->{wb}; | |
| 562 | |||
| 563 | 0 | $wb->{q}->param('continent', 'Asia'); | |
| 564 | 0 | $wb->{q}->param('_browse_skip_to_results_', 1); | |
| 565 | |||
| 566 | 0 | $self->assert(! $wb->is_browsing()); | |
| 567 | 0 | $self->assert_equals('state_or_province', $wb->parent_category_column()); | |
| 568 | 0 | $self->assert_deep_equals([qw/continent nation state_or_province/], [$self->{wb}->ancestor_category_columns()]); | |
| 569 | 0 | $self->assert_display_contains( | |
| 570 | # test for hidden _browse_skip_to_results_: required for persistent results where subclasses submit form | ||
| 571 | [ 'input type="hidden" name="_browse_skip_to_results_" value="1' ], | ||
| 572 | [ 'input type="hidden" name="continent" value="Asia' ], | ||
| 573 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 574 | [ 'sortby=city_no', 'continent=Asia', 'city_no' ], | ||
| 575 | [ 'sortby=name', 'continent=Asia', 'name' ], | ||
| 576 | [ 'sortby=population', 'continent=Asia', 'population' ], | ||
| 577 | [ 'At first page', 'At last page' ], | ||
| 578 | [ 'tr', 'td' ], | ||
| 579 | [ 'Tokyo', 'Largest city in the world', 34_450_000 ], | ||
| 580 | [ 'Mumbai', 'Largest city in India, capital of western state of Maharashtra', 19_380_000 ], | ||
| 581 | [ 'Bangkok', 'City with the longest full name in the world', 8_190_000 ], | ||
| 582 | [ 'td', 'tr' ], | ||
| 583 | [ 'At first page', 'At last page' ], | ||
| 584 | ); | ||
| 585 | 0 | $self->assert_equals('Asia (all results)', $wb->category_title()); | |
| 586 | |||
| 587 | 0 | $self->assert_display_does_not_contain([ 'input type="hidden" name="nation' ]); | |
| 588 | 0 | $self->assert_display_does_not_contain([ 'continent=Asia[^<>]+id="categoryNavLink-', 'Japan' ]); | |
| 589 | 0 | $self->assert_display_does_not_contain([ 'continent=Asia[^<>]+id="categoryNavLink-', 'India' ]); | |
| 590 | 0 | $self->assert_display_does_not_contain([ 'continent=Asia[^<>]+id="categoryNavLink-', 'Thailand' ]); | |
| 591 | } | ||
| 592 | |||
| 593 | sub test_display__auto_skip_to_results_from_category_navigation | ||
| 594 | 0 | ▶ | { |
|
Subroutine
test_display__auto_skip_to_results_from_category_navigation: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 595 | 0 | my $self = shift; | |
| 596 | 0 | my $wb = $self->{wb}; | |
| 597 | |||
| 598 | 0 | my $sth1 = $self->{-dbh}->prepare_cached(q{ | |
| 599 | insert into cities (continent, country, name, description) values (?, ?, ?, ?) | ||
| 600 | }); | ||
| 601 | 0 | $sth1->execute('Antarctica', undef, 'Penguin Camp 1', 'Home of Linux'); | |
| 602 | 0 | $sth1->execute('Pacific Ocean', '', 'Tahiti Village', 'Pacific island village of Tahiti'); | |
| 603 | 0 | $sth1->execute('Pacific Ocean', '', 'Samoa', 'Pacific island of Samoa'); | |
| 604 | 0 | $sth1->execute('Atlantic Ocean', ' ***** ', 'Trade winds', 'Atlantic hurricane central'); | |
| 605 | # end setup | ||
| 606 | |||
| 607 | 0 | $wb->{q}->param('continent', 'Antarctica'); | |
| 608 | |||
| 609 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 610 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 611 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 612 | |||
| 613 | 0 | $self->assert_display_contains( | |
| 614 | [ 'continent=Antarctica&_browse_skip_to_results_=1"[^<>]+id="skipToResultsLink', | ||
| 615 | "Show all items in this category" ], | ||
| 616 | [ 'input type="hidden" name="continent" value="Antarctica' ], | ||
| 617 | ); | ||
| 618 | 0 | $self->assert_display_does_not_contain(['Penguin Camp 1']); | |
| 619 | 0 | $self->assert_display_does_not_contain(['Home of Linux']); | |
| 620 | |||
| 621 | 0 | $self->assert_equals('Antarctica', $wb->category_title()); | |
| 622 | |||
| 623 | 0 | $self->init_test_object(); | |
| 624 | 0 | $wb = $self->{wb}; | |
| 625 | 0 | $wb->{-auto_skip_to_results} = 1; # enable auto_skip_to_results feature | |
| 626 | |||
| 627 | 0 | $wb->{q}->param('continent', 'Antarctica'); | |
| 628 | |||
| 629 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 630 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 631 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 632 | |||
| 633 | 0 | $self->assert_display_contains( | |
| 634 | [ 'input type="hidden" name="continent" value="Antarctica' ], | ||
| 635 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 636 | |||
| 637 | [ 'sortby=city_no', 'continent=Antarctica', 'city_no' ], | ||
| 638 | [ 'sortby=name', 'continent=Antarctica', 'name' ], | ||
| 639 | [ 'sortby=description', 'continent=Antarctica', 'description' ], | ||
| 640 | [ 'sortby=population', 'continent=Antarctica', 'population' ], | ||
| 641 | [ 'sortby=state_or_province', 'continent=Antarctica', 'state_or_province' ], | ||
| 642 | [ 'sortby=nation', 'continent=Antarctica', 'nation' ], | ||
| 643 | |||
| 644 | [ 'At first page', 'At last page' ], | ||
| 645 | [ 'tr', 'td' ], | ||
| 646 | [ 'Penguin Camp 1', 'Home of Linux' ], | ||
| 647 | [ 'td', 'tr' ], | ||
| 648 | [ 'At first page', 'At last page' ], | ||
| 649 | ); | ||
| 650 | |||
| 651 | # note that these changed after $wb->search, since we detected no category members and skipped to results | ||
| 652 | 0 | $self->assert(! $wb->is_browsing()); | |
| 653 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 654 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 655 | |||
| 656 | 0 | $self->assert_equals('Antarctica', $wb->category_title()); | |
| 657 | |||
| 658 | 0 | $self->assert_display_does_not_contain([ 'categoryNavLink-' ]); | |
| 659 | |||
| 660 | 0 | $self->init_test_object(); | |
| 661 | 0 | $wb = $self->{wb}; | |
| 662 | 0 | $wb->{-auto_skip_to_results} = 1; # enable auto_skip_to_results feature | |
| 663 | |||
| 664 | 0 | $wb->{q}->param('continent', 'Pacific Ocean'); | |
| 665 | |||
| 666 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 667 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 668 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 669 | |||
| 670 | 0 | $self->assert_display_contains( | |
| 671 | [ 'input type="hidden" name="continent" value="Pacific Ocean' ], | ||
| 672 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 673 | |||
| 674 | [ 'sortby=city_no', 'continent=Pacific%20Ocean', 'city_no' ], | ||
| 675 | [ 'sortby=name', 'continent=Pacific%20Ocean', 'name' ], | ||
| 676 | [ 'sortby=description', 'continent=Pacific%20Ocean', 'description' ], | ||
| 677 | [ 'sortby=population', 'continent=Pacific%20Ocean', 'population' ], | ||
| 678 | [ 'sortby=state_or_province', 'continent=Pacific%20Ocean', 'state_or_province' ], | ||
| 679 | [ 'sortby=nation', 'continent=Pacific%20Ocean', 'nation' ], | ||
| 680 | |||
| 681 | [ 'At first page', 'At last page' ], | ||
| 682 | [ 'tr', 'td' ], | ||
| 683 | [ 'Tahiti Village', 'Pacific island village of Tahiti' ], | ||
| 684 | [ 'Samoa', 'Pacific island of Samoa' ], | ||
| 685 | [ 'td', 'tr' ], | ||
| 686 | [ 'At first page', 'At last page' ], | ||
| 687 | ); | ||
| 688 | |||
| 689 | # note that these changed after $wb->search, since we detected no category members and skipped to results | ||
| 690 | 0 | $self->assert(! $wb->is_browsing()); | |
| 691 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 692 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 693 | |||
| 694 | 0 | $self->assert_equals('Pacific Ocean', $wb->category_title()); | |
| 695 | |||
| 696 | 0 | $self->assert_display_does_not_contain([ 'categoryNavLink-' ]); | |
| 697 | |||
| 698 | 0 | $self->init_test_object(); | |
| 699 | 0 | $wb = $self->{wb}; | |
| 700 | 0 | $wb->{-auto_skip_to_results} = 1; # enable auto_skip_to_results feature | |
| 701 | |||
| 702 | 0 | $wb->{q}->param('continent', 'Atlantic Ocean'); | |
| 703 | |||
| 704 | 0 | $self->assert_equals('nation', $wb->is_browsing()); | |
| 705 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 706 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 707 | |||
| 708 | 0 | $self->assert_display_contains( | |
| 709 | [ 'input type="hidden" name="continent" value="Atlantic Ocean' ], | ||
| 710 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 711 | |||
| 712 | [ 'sortby=city_no', 'continent=Atlantic%20Ocean', 'city_no' ], | ||
| 713 | [ 'sortby=name', 'continent=Atlantic%20Ocean', 'name' ], | ||
| 714 | [ 'sortby=description', 'continent=Atlantic%20Ocean', 'description' ], | ||
| 715 | [ 'sortby=population', 'continent=Atlantic%20Ocean', 'population' ], | ||
| 716 | [ 'sortby=state_or_province', 'continent=Atlantic%20Ocean', 'state_or_province' ], | ||
| 717 | [ 'sortby=nation', 'continent=Atlantic%20Ocean', 'nation' ], | ||
| 718 | |||
| 719 | [ 'At first page', 'At last page' ], | ||
| 720 | [ 'tr', 'td' ], | ||
| 721 | [ 'Trade winds', 'Atlantic hurricane central' ], | ||
| 722 | [ 'td', 'tr' ], | ||
| 723 | [ 'At first page', 'At last page' ], | ||
| 724 | ); | ||
| 725 | |||
| 726 | # note that these changed after $wb->search, since we detected no category members and skipped to results | ||
| 727 | 0 | $self->assert(! $wb->is_browsing()); | |
| 728 | 0 | $self->assert_equals('continent', $wb->parent_category_column()); | |
| 729 | 0 | $self->assert_deep_equals([qw/continent/], [$self->{wb}->ancestor_category_columns()]); | |
| 730 | |||
| 731 | 0 | $self->assert_equals('Atlantic Ocean', $wb->category_title()); | |
| 732 | |||
| 733 | 0 | $self->assert_display_does_not_contain([ 'categoryNavLink-' ]); | |
| 734 | } | ||
| 735 | |||
| 736 | sub test_display__records_aka_leaf_nodes | ||
| 737 | 0 | ▶ | { |
|
Subroutine
test_display__records_aka_leaf_nodes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 738 | 0 | my $self = shift; | |
| 739 | 0 | my $wb = $self->{wb}; | |
| 740 | |||
| 741 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 742 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 743 | 0 | $wb->{q}->param('state_or_province', 'Oregon'); | |
| 744 | |||
| 745 | 0 | $self->assert(! $wb->is_browsing()); | |
| 746 | 0 | $self->assert_equals('state_or_province', $wb->parent_category_column()); | |
| 747 | 0 | $self->assert_deep_equals([qw/continent nation state_or_province/], [$self->{wb}->ancestor_category_columns()]); | |
| 748 | 0 | $self->assert_display_contains( | |
| 749 | [ 'input type="hidden" name="continent" value="North America' ], | ||
| 750 | [ 'input type="hidden" name="nation" value="United States' ], | ||
| 751 | [ 'input type="hidden" name="state_or_province" value="Oregon' ], | ||
| 752 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 753 | [ 'sortby=city_no', 'state_or_province=Oregon', 'city_no' ], | ||
| 754 | [ 'sortby=name', 'nation=United%20States', 'name' ], | ||
| 755 | [ 'sortby=population', 'continent=North%20America', 'population' ], | ||
| 756 | [ 'At first page', 'At last page' ], | ||
| 757 | [ 'tr', 'td' ], | ||
| 758 | [ 'Portland', 'Microbrew capital of the world', 1_583_138 ], | ||
| 759 | [ 'td', 'tr' ], | ||
| 760 | [ 'At first page', 'At last page' ], | ||
| 761 | ); | ||
| 762 | 0 | $self->assert_equals('North America > United States > Oregon (results)', $wb->category_title()); | |
| 763 | |||
| 764 | 0 | $self->assert_display_does_not_contain([ 'continent=North%20America', 'id="categoryNavLink-' ]); | |
| 765 | 0 | $self->assert_display_does_not_contain([ 'nation=United%20States', 'id="categoryNavLink-' ]); | |
| 766 | 0 | $self->assert_display_does_not_contain([ 'state_or_province=Oregon', 'id="categoryNavLink-' ]); | |
| 767 | |||
| 768 | 0 | $self->init_test_object(); | |
| 769 | 0 | $wb = $self->{wb}; | |
| 770 | |||
| 771 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 772 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 773 | 0 | $wb->{q}->param('state_or_province', 'New York'); | |
| 774 | |||
| 775 | 0 | $self->assert(! $wb->is_browsing()); | |
| 776 | 0 | $self->assert_equals('state_or_province', $wb->parent_category_column()); | |
| 777 | 0 | $self->assert_deep_equals([qw/continent nation state_or_province/], [$self->{wb}->ancestor_category_columns()]); | |
| 778 | 0 | $self->assert_display_contains( | |
| 779 | [ 'input type="hidden" name="continent" value="North America' ], | ||
| 780 | [ 'input type="hidden" name="nation" value="United States' ], | ||
| 781 | [ 'input type="hidden" name="state_or_province" value="New York' ], | ||
| 782 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 783 | [ 'sortby=city_no', 'state_or_province=New%20York', 'city_no' ], | ||
| 784 | [ 'sortby=name', 'nation=United%20States', 'name' ], | ||
| 785 | [ 'sortby=population', 'continent=North%20America', 'population' ], | ||
| 786 | [ 'At first page', 'At last page' ], | ||
| 787 | [ 'tr', 'td' ], | ||
| 788 | [ 'New York', 'Financial capital of the world', 20_420_000 ], | ||
| 789 | [ 'Ithaca', 'Ithaca is Gorges', 100_018 ], | ||
| 790 | [ 'td', 'tr' ], | ||
| 791 | [ 'At first page', 'At last page' ], | ||
| 792 | ); | ||
| 793 | 0 | $self->assert_equals('North America > United States > New York (results)', $wb->category_title()); | |
| 794 | |||
| 795 | 0 | $self->assert_display_does_not_contain([ 'state_or_province=New%20York', 'id="categoryNavLink-' ]); | |
| 796 | |||
| 797 | 0 | $self->init_test_object(); | |
| 798 | 0 | $wb = $self->{wb}; | |
| 799 | |||
| 800 | 0 | $wb->{q}->param('continent', 'Asia'); | |
| 801 | 0 | $wb->{q}->param('nation', 'India'); | |
| 802 | 0 | $wb->{q}->param('state_or_province', 'Maharashtra'); | |
| 803 | |||
| 804 | 0 | $self->assert(! $wb->is_browsing()); | |
| 805 | 0 | $self->assert_equals('state_or_province', $wb->parent_category_column()); | |
| 806 | 0 | $self->assert_deep_equals([qw/continent nation state_or_province/], [$self->{wb}->ancestor_category_columns()]); | |
| 807 | 0 | $self->assert_display_contains( | |
| 808 | [ 'input type="hidden" name="continent" value="Asia' ], | ||
| 809 | [ 'input type="hidden" name="nation" value="India' ], | ||
| 810 | [ 'input type="hidden" name="state_or_province" value="Maharashtra' ], | ||
| 811 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 812 | [ 'sortby=city_no', 'continent=Asia', 'city_no' ], | ||
| 813 | [ 'sortby=name', 'nation=India', 'name' ], | ||
| 814 | [ 'sortby=population', 'state_or_province=Maharashtra', 'population' ], | ||
| 815 | [ 'At first page', 'At last page' ], | ||
| 816 | [ 'tr', 'td' ], | ||
| 817 | [ 'Mumbai', 'Largest city in India, capital of western state of Maharashtra', 19_380_000 ], | ||
| 818 | [ 'td', 'tr' ], | ||
| 819 | [ 'At first page', 'At last page' ], | ||
| 820 | ); | ||
| 821 | 0 | $self->assert_equals('Asia > India > Maharashtra (results)', $wb->category_title()); | |
| 822 | |||
| 823 | 0 | $self->assert_display_does_not_contain([ 'continent=Asia', 'id="categoryNavLink-' ]); | |
| 824 | 0 | $self->assert_display_does_not_contain([ 'nation=India', 'id="categoryNavLink-' ]); | |
| 825 | 0 | $self->assert_display_does_not_contain([ 'state_or_province=Maharashtra', 'id="categoryNavLink-' ]); | |
| 826 | |||
| 827 | 0 | $self->init_test_object(); | |
| 828 | 0 | $wb = $self->{wb}; | |
| 829 | |||
| 830 | 0 | $wb->{q}->param('continent', 'Asia'); | |
| 831 | 0 | $wb->{q}->param('nation', 'Japan'); | |
| 832 | 0 | $wb->{q}->param('state_or_province', 'Kanto'); | |
| 833 | |||
| 834 | 0 | $self->assert(! $wb->is_browsing()); | |
| 835 | 0 | $self->assert_equals('state_or_province', $wb->parent_category_column()); | |
| 836 | 0 | $self->assert_deep_equals([qw/continent nation state_or_province/], [$self->{wb}->ancestor_category_columns()]); | |
| 837 | 0 | $self->assert_display_contains( | |
| 838 | [ 'input type="hidden" name="continent" value="Asia' ], | ||
| 839 | [ 'input type="hidden" name="nation" value="Japan' ], | ||
| 840 | [ 'input type="hidden" name="state_or_province" value="Kanto' ], | ||
| 841 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 842 | [ 'sortby=city_no', 'state_or_province=Kanto', 'city_no' ], | ||
| 843 | [ 'sortby=name', 'state_or_province=Kanto', 'name' ], | ||
| 844 | [ 'sortby=population', 'state_or_province=Kanto', 'population' ], | ||
| 845 | [ 'At first page', 'At last page' ], | ||
| 846 | [ 'tr', 'td' ], | ||
| 847 | [ 'Tokyo', 'Largest city in the world', 34_450_000 ], | ||
| 848 | [ 'td', 'tr' ], | ||
| 849 | [ 'At first page', 'At last page' ], | ||
| 850 | ); | ||
| 851 | 0 | $self->assert_equals('Asia > Japan > Kanto (results)', $wb->category_title()); | |
| 852 | |||
| 853 | 0 | $self->assert_display_does_not_contain([ 'continent=Asia', 'id="categoryNavLink-' ]); | |
| 854 | 0 | $self->assert_display_does_not_contain([ 'nation=Japan', 'id="categoryNavLink-' ]); | |
| 855 | 0 | $self->assert_display_does_not_contain([ 'state_or_province=Kanto', 'id="categoryNavLink-' ]); | |
| 856 | } | ||
| 857 | |||
| 858 | sub test_display__records_with_column_using_link_for_category_column | ||
| 859 | 0 | ▶ | { |
|
Subroutine
test_display__records_with_column_using_link_for_category_column: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 860 | 0 | my $self = shift; | |
| 861 | 0 | my $wb = $self->{wb}; | |
| 862 | 0 | $wb->{q}->param('href_testvar', 'foo'); | |
| 863 | 0 | $wb->{q}->param('href_testvar2', 'bar'); | |
| 864 | 0 | $wb->{ws}->{-href_extra_vars} = { href_testvar => undef, href_testvar2 => undef }; | |
| 865 | |||
| 866 | 0 | ▶ | $wb->{ws}->{-columndata_closures}->{'state_or_province'} = sub { |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 867 | 0 | my ($obj, $row) = @_; | |
| 868 | 0 | return $obj->{b}->link_for_category_column('state_or_province', $row, 'href_testvar2'); | |
| 869 | 0 | }; | |
| 870 | # note: for this to work correctly, all category columns must be retrieved in | ||
| 871 | # -sql_retrieve_columns, so we have to add 'continent' since it is not retrieved by default | ||
| 872 | 0 | push(@{ $wb->{ws}->{-sql_retrieve_columns} }, 'continent'); | |
| 873 | |||
| 874 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 875 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 876 | 0 | $wb->{q}->param('state_or_province', 'Oregon'); | |
| 877 | |||
| 878 | 0 | $self->assert_display_contains( | |
| 879 | [ 'Portland', 'Microbrew capital of the world', 1_583_138, | ||
| 880 | 'a href="\?continent=North%20America&nation=United%20States&state_or_province=Oregon\S*&href_testvar=foo" id="jumpToCategoryLink"[^<>]*>Oregon' ], | ||
| 881 | ); | ||
| 882 | 0 | $self->assert_display_does_not_contain([ '[^<>]*href_testvar2[^<>]*id="jumpToCategoryLink' ] ); | |
| 883 | 0 | $self->assert_display_does_not_contain([ 'continent=North%20America\S*continent=North%20America' ] ); | |
| 884 | 0 | $self->assert_display_does_not_contain([ 'nation=United%20States\S*nation=United%20States' ] ); | |
| 885 | 0 | $self->assert_display_does_not_contain([ 'state_or_province=Oregon\S*state_or_province=Oregon' ] ); | |
| 886 | } | ||
| 887 | |||
| 888 | sub test_display__paging_records | ||
| 889 | 0 | ▶ | { |
|
Subroutine
test_display__paging_records: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 890 | 0 | my $self = shift; | |
| 891 | 0 | my $wb = $self->{wb}; | |
| 892 | 0 | $wb->{ws}->{-max_results_per_page} = 1; | |
| 893 | |||
| 894 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 895 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 896 | 0 | $wb->{q}->param('state_or_province', 'New York'); | |
| 897 | 0 | $self->assert_display_contains( | |
| 898 | [ 'At first page', 'search_startat=1', 'Next >' ], | ||
| 899 | [ 'tr', 'td' ], | ||
| 900 | [ 'New York', 'Financial capital of the world', 20_420_000 ], | ||
| 901 | [ 'td', 'tr' ], | ||
| 902 | [ 'At first page', 'search_startat=1', 'Next >' ], | ||
| 903 | ); | ||
| 904 | |||
| 905 | 0 | $self->init_test_object(); | |
| 906 | 0 | $wb = $self->{wb}; | |
| 907 | 0 | $wb->{ws}->{-max_results_per_page} = 1; | |
| 908 | |||
| 909 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 910 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 911 | 0 | $wb->{q}->param('state_or_province', 'New York'); | |
| 912 | 0 | $wb->{q}->param('search_startat', 1); | |
| 913 | 0 | $self->assert_display_contains( | |
| 914 | [ 'search_startat=0', 'lt; Previous', 'At last page' ], | ||
| 915 | [ 'tr', 'td' ], | ||
| 916 | [ 'Ithaca', 'Ithaca is Gorges', 100_018 ], | ||
| 917 | [ 'td', 'tr' ], | ||
| 918 | [ 'search_startat=0', 'lt; Previous', 'At last page' ], | ||
| 919 | ); | ||
| 920 | } | ||
| 921 | |||
| 922 | sub test_display__breadcrumb_navigation | ||
| 923 | 0 | ▶ | { |
|
Subroutine
test_display__breadcrumb_navigation: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 924 | 0 | my $self = shift; | |
| 925 | 0 | my $wb = $self->{wb}; | |
| 926 | |||
| 927 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 928 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 929 | 0 | $wb->{q}->param('state_or_province', 'New York'); | |
| 930 | 0 | $self->assert_display_contains( | |
| 931 | [ 'href="?"[^<>]+class="breadcrumbNavLink', 'Top', 'gt' ], | ||
| 932 | [ 'continent=North%20America', 'class="breadcrumbNavLink', 'North America', 'gt' ], | ||
| 933 | [ 'continent=North%20America', 'nation=United%20States', 'class="breadcrumbNavLink', 'United States', 'gt' ], | ||
| 934 | [ 'continent=North%20America', 'nation=United%20States', 'state_or_province=New%20York', 'class="breadcrumbNavLink', 'New York' ], | ||
| 935 | [ 'Sort by', 'sortby_columns_popup', 'Sort field' ], | ||
| 936 | [ 'At first page', 'At last page' ], | ||
| 937 | [ 'tr', 'td' ], | ||
| 938 | [ 'New York', 'Financial capital of the world', 20_420_000 ], | ||
| 939 | [ 'Ithaca', 'Ithaca is Gorges', 100_018 ], | ||
| 940 | [ 'td', 'tr' ], | ||
| 941 | [ 'At first page', 'At last page' ], | ||
| 942 | ); | ||
| 943 | 0 | $self->assert_deep_equals(['Top', 'North America', 'United States', 'New York'], $wb->{'breadcrumbs'}); | |
| 944 | $self->assert_matches( | ||
| 945 | $self->word_sequence_regex_for_rows([ 'href="\?"[^<>]+class="breadcrumbNavLink', 'Top' ]), | ||
| 946 | 0 | $wb->{'breadcrumb_links'}->[0], | |
| 947 | ); | ||
| 948 | $self->assert_matches( | ||
| 949 | $self->word_sequence_regex_for_rows([ 'continent=North%20America', 'class="breadcrumbNavLink', 'North America' ]), | ||
| 950 | 0 | $wb->{'breadcrumb_links'}->[1], | |
| 951 | ); | ||
| 952 | $self->assert_matches( | ||
| 953 | $self->word_sequence_regex_for_rows([ 'continent=North%20America', 'nation=United%20States', 'class="breadcrumbNavLink', 'United States' ]), | ||
| 954 | 0 | $wb->{'breadcrumb_links'}->[2], | |
| 955 | ); | ||
| 956 | $self->assert_matches( | ||
| 957 | $self->word_sequence_regex_for_rows([ 'continent=North%20America', 'nation=United%20States', 'state_or_province=New%20York', 'class="breadcrumbNavLink', 'New York' ]), | ||
| 958 | 0 | $wb->{'breadcrumb_links'}->[3], | |
| 959 | ); | ||
| 960 | |||
| 961 | 0 | $self->assert_display_does_not_contain([ 'state_or_province=New%20York', 'id="categoryNavLink-' ]); | |
| 962 | |||
| 963 | 0 | $self->init_test_object(); | |
| 964 | 0 | $wb = $self->{wb}; | |
| 965 | 0 | $wb->{q}->param('href_testvar', 'foo'); | |
| 966 | 0 | $wb->{ws}->{-href_extra_vars} = { href_testvar => undef }; | |
| 967 | |||
| 968 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 969 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 970 | 0 | $self->assert_display_contains( | |
| 971 | [ 'href="?"[^<>]+class="breadcrumbNavLink', 'Top', 'gt' ], | ||
| 972 | [ 'continent=North%20America', 'href_testvar=foo', 'class="breadcrumbNavLink', 'North America', 'gt' ], | ||
| 973 | [ 'continent=North%20America', 'nation=United%20States', 'href_testvar=foo', 'class="breadcrumbNavLink', 'United States' ], | ||
| 974 | |||
| 975 | [ 'state_or_province=New%20York', 'href_testvar=foo', 'id="categoryNavLink-New York".*', 'New York, United States' ], | ||
| 976 | [ 'state_or_province=Oregon', 'href_testvar=foo', 'id="categoryNavLink-Oregon".*', 'Oregon, United States' ], | ||
| 977 | ); | ||
| 978 | |||
| 979 | 0 | $self->init_test_object(); | |
| 980 | 0 | $wb = $self->{wb}; | |
| 981 | 0 | $wb->{-exclude_vars_from_breadcrumbs} = [ 'href_testvar2' ]; | |
| 982 | 0 | $wb->{q}->param('href_testvar', 'foo'); | |
| 983 | 0 | $wb->{q}->param('href_testvar2', 'bar'); | |
| 984 | 0 | $wb->{ws}->{-href_extra_vars} = { href_testvar => undef, href_testvar2 => undef }; | |
| 985 | |||
| 986 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 987 | 0 | $wb->{q}->param('nation', 'United States'); | |
| 988 | 0 | $self->assert_display_contains( | |
| 989 | [ 'href="?"[^<>]+class="breadcrumbNavLink', 'Top', 'gt' ], | ||
| 990 | [ 'continent=North%20America', 'href_testvar=foo', 'class="breadcrumbNavLink', 'North America', 'gt' ], | ||
| 991 | [ 'continent=North%20America', 'nation=United%20States', 'href_testvar=foo', 'class="breadcrumbNavLink', 'United States' ], | ||
| 992 | |||
| 993 | [ 'state_or_province=New%20York', 'href_testvar(?:=foo|2=bar)', 'href_testvar(?:=foo|2=bar)', 'id="categoryNavLink-New York".*', 'New York, United States' ], | ||
| 994 | [ 'state_or_province=Oregon', 'href_testvar(?:=foo|2=bar)', 'href_testvar(?:=foo|2=bar)', 'id="categoryNavLink-Oregon".*', 'Oregon, United States' ], | ||
| 995 | ); | ||
| 996 | 0 | $self->assert_display_does_not_contain([ 'href_testvar2=bar[^<>]*class="breadcrumbNavLink' ]); | |
| 997 | } | ||
| 998 | |||
| 999 | sub test_display__passing_where_clause_and_bind_params | ||
| 1000 | 0 | ▶ | { |
|
Subroutine
test_display__passing_where_clause_and_bind_params: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 1001 | 0 | my $self = shift; | |
| 1002 | 0 | my $wb = $self->{wb}; | |
| 1003 | 0 | $wb->{ws}->{-where_clause} = 'continent LIKE ?'; | |
| 1004 | 0 | $wb->{ws}->{-bind_params} = ['A%']; | |
| 1005 | |||
| 1006 | 0 | $self->assert_display_contains( | |
| 1007 | [ 'tr', 'td' ], | ||
| 1008 | [ 'continent=Africa[^<>]+id="categoryNavLink-Africa".*', 'Africa' ], | ||
| 1009 | [ 'continent=Asia[^<>]+id="categoryNavLink-Asia".*', 'Asia' ], | ||
| 1010 | [ 'continent=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 1011 | [ 'td', 'tr' ], | ||
| 1012 | ); | ||
| 1013 | 0 | $self->assert_display_does_not_contain([ 'Europe' ]); | |
| 1014 | 0 | $self->assert_display_does_not_contain([ 'America' ]); | |
| 1015 | |||
| 1016 | 0 | $self->init_test_object(); | |
| 1017 | 0 | $wb = $self->{wb}; | |
| 1018 | 0 | $wb->{ws}->{-where_clause} = 'cities.state_or_province = ?'; | |
| 1019 | 0 | $wb->{ws}->{-bind_params} = ['Oregon']; | |
| 1020 | |||
| 1021 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 1022 | 0 | $self->assert_display_contains( | |
| 1023 | [ 'tr', 'td' ], | ||
| 1024 | [ 'continent=North%20America&nation=United%20States[^<>]+id="categoryNavLink-United States".*', 'United States' ], | ||
| 1025 | [ 'td', 'tr' ], | ||
| 1026 | ); | ||
| 1027 | # test Canada not listed at all | ||
| 1028 | 0 | $self->assert_display_does_not_contain([ 'Canada' ]); | |
| 1029 | } | ||
| 1030 | |||
| 1031 | sub test_display__passing_href_extra_vars | ||
| 1032 | 0 | ▶ | { |
|
Subroutine
test_display__passing_href_extra_vars: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 1033 | 0 | my $self = shift; | |
| 1034 | 0 | my $wb = $self->{wb}; | |
| 1035 | 0 | $wb->{-max_category_results_per_page} = 3; | |
| 1036 | 0 | $wb->{ws}->{-href_extra_vars} = { myVar1 => undef, myVar2 => 'constant' }; | |
| 1037 | |||
| 1038 | 0 | $self->assert_display_contains( | |
| 1039 | [ 'At first page', '3', 'results displayed', '1 - 3', 'of', '6', 'search_startat=1\S+myVar2=constant', 'Next >' ], | ||
| 1040 | [ 'tr', 'td' ], | ||
| 1041 | [ 'continent=Africa[^<>]+id="categoryNavLink-Africa".*', 'Africa' ], | ||
| 1042 | [ 'continent=Asia[^<>]+id="categoryNavLink-Asia".*', 'Asia' ], | ||
| 1043 | [ 'continent=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 1044 | [ 'td', 'tr' ], | ||
| 1045 | [ 'At first page', 'search_startat=1\S+myVar2=constant', 'Next >' ], | ||
| 1046 | ); | ||
| 1047 | 0 | $self->assert_display_does_not_contain([ 'myVar1=' ]); | |
| 1048 | |||
| 1049 | 0 | $self->init_test_object(); | |
| 1050 | 0 | $wb = $self->{wb}; | |
| 1051 | |||
| 1052 | 0 | $wb->{-max_category_results_per_page} = 3; | |
| 1053 | 0 | $wb->{ws}->{-href_extra_vars} = { myVar1 => undef, myVar2 => 'constant' }; | |
| 1054 | 0 | $wb->{q}->param('myVar1', 'foo'); | |
| 1055 | # test that both myVar1 and myVar2 params are in navigation link | ||
| 1056 | 0 | $self->assert_display_contains( | |
| 1057 | [ 'At first page', '3', 'results displayed', '1 - 3', 'of', '6', 'search_startat=1', 'myVar1=foo', 'Next >' ], | ||
| 1058 | [ 'tr', 'td' ], | ||
| 1059 | [ 'continent=Africa[^<>]+id="categoryNavLink-Africa".*', 'Africa' ], | ||
| 1060 | [ 'continent=Asia[^<>]+id="categoryNavLink-Asia".*', 'Asia' ], | ||
| 1061 | [ 'continent=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 1062 | [ 'td', 'tr' ], | ||
| 1063 | [ 'At first page', 'search_startat=1', 'myVar2=constant', 'Next >' ], | ||
| 1064 | ); | ||
| 1065 | } | ||
| 1066 | |||
| 1067 | sub test_display__with_sql_search_columns_and_join_for_dataset | ||
| 1068 | 0 | ▶ | { |
|
Subroutine
test_display__with_sql_search_columns_and_join_for_dataset: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 1069 | 0 | my $self = shift; | |
| 1070 | 0 | my $wb = $self->{wb}; | |
| 1071 | 0 | $wb->{ws}->{-sql_search_columns} = [qw/city_no continent/]; | |
| 1072 | 0 | $wb->{ws}->{-sql_join_for_dataset} = 'inner join cities using (city_no)'; | |
| 1073 | 0 | $wb->{ws}->{-where_clause} = 'continent LIKE ?'; | |
| 1074 | 0 | $wb->{ws}->{-bind_params} = ['A%']; | |
| 1075 | |||
| 1076 | 0 | $self->assert_display_contains( | |
| 1077 | [ 'tr', 'td' ], | ||
| 1078 | [ 'continent=Africa[^<>]+id="categoryNavLink-Africa".*', 'Africa' ], | ||
| 1079 | [ 'continent=Asia[^<>]+id="categoryNavLink-Asia".*', 'Asia' ], | ||
| 1080 | [ 'continent=Australia[^<>]+id="categoryNavLink-Australia".*', 'Australia' ], | ||
| 1081 | [ 'td', 'tr' ], | ||
| 1082 | ); | ||
| 1083 | 0 | $self->assert_display_does_not_contain([ 'Europe' ]); | |
| 1084 | 0 | $self->assert_display_does_not_contain([ 'America' ]); | |
| 1085 | |||
| 1086 | 0 | $self->init_test_object(); | |
| 1087 | 0 | $wb = $self->{wb}; | |
| 1088 | 0 | $wb->{ws}->{-where_clause} = 'cities.state_or_province = ?'; | |
| 1089 | 0 | $wb->{ws}->{-bind_params} = ['Oregon']; | |
| 1090 | |||
| 1091 | 0 | $wb->{q}->param('continent', 'North America'); | |
| 1092 | 0 | $self->assert_display_contains( | |
| 1093 | [ 'tr', 'td' ], | ||
| 1094 | [ 'continent=North%20America&nation=United%20States[^<>]+id="categoryNavLink-United States".*', 'United States' ], | ||
| 1095 | [ 'td', 'tr' ], | ||
| 1096 | ); | ||
| 1097 | # test Canada not listed at all | ||
| 1098 | 0 | $self->assert_display_does_not_contain([ 'Canada' ]); | |
| 1099 | } | ||
| 1100 | |||
| 1101 | |||
| 1102 | 1 | 1; | |