MODE=TAP,80

BEGINPERL

my $mech = webui_login(
  username => 'admin',
  password => 'nimda',
  url      => "http://$webhost",
);

for my $link (sort { $a->url cmp $b->url } $mech->links()) {
    my $url = $link->url();

    # Only consider local pages.
    next unless $url =~ m,^/,;

    # Don't logout...
    next if $url =~ m,logout$,;

    check_url($url);
}

# Finally check logout...
check_url("/index.php?logout");

sub check_url {
    my $url = shift;

    my $failed = 0;
    $url = "http://$webhost$url";

    $mech->get_ok($url, "Fetch page - $url")
        || do { $failed = 1 };
    ok($mech->response->code == 200, "Page has HTTP status 200 - $url")
        || do {
        diag("HTTP Status: " . $mech->status());
        $failed = 1;
    };
    $mech->content_lacks('<b>Deprecated</b>:',
        "Page free of Dreprecated warnings - $url")
        || do { $failed = 1 };
    $mech->content_lacks('<b>Warning</b>:',
        "Page free of Warning warnings - $url")
        || do { $failed = 1 };

    if ($failed) {
        $url =~ s,[/:],_,g;
        diag("Saved content of $url to $save_location/$case-$url");
        $mech->save_content("$save_location/$case-$url", binmode => ':utf8');
    }
}

ENDPERL
