Skip to content

Commit

Permalink
Added t/display.t
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelhorne committed Nov 22, 2024
1 parent 5605959 commit 64e9a1d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Revision history for Geo-Coder-Free

0.38
Latest as_string return code from VWF
Added t/config.t
Added t/config.t, t/utils.t and t/display.t

0.37 Wed Oct 23 10:09:54 EDT 2024
Allow new() to take HASH ref
Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ t/cities.t
t/comment-spelling.t
t/config.t
t/critic.t
t/display.t
t/dr5hn.t
t/eof.t
t/eol.t
Expand Down
2 changes: 2 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ WriteMakefile(
PREREQ_PM => {
'Carp' => 0,
# 'BerkeleyDB' => 0,
'Cwd' => 0,
'Data::Validate::URI' => 0,
'DB_File' => 0,
'DBI' => 0,
'Digest::MD5' => 0,
Expand Down
57 changes: 57 additions & 0 deletions t/display.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env perl

use strict;
use warnings;
use Cwd;
use Test::Most tests => 8;
use Data::Validate::URI;

BEGIN { use_ok('Geo::Coder::Free::Display') }

# Simulate environment variables
local %ENV = (
HTTP_REFERER => 'http://example.com',
REMOTE_ADDR => '127.0.0.1',
CONFIG_DIR => undef,
DOCUMENT_ROOT => '/var/www',
HOME => '/home/user',
GATEWAY_INTERFACE => 'CGI/1.1',
REQUEST_METHOD => 'GET',
QUERY_STRING => 'foo=bar&baz=qux',
SCRIPT_URI => 'http://localhost',
);

# Create an instance of the module
my $display = Geo::Coder::Free::Display->new(

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.32 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.30 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.28 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.22 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.34 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.36 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.40 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.38 on macos-latest

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.22 on macos-14

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.28 on macos-14

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.34 on macos-14

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.30 on macos-14

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.32 on macos-14

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.36 on macos-14

Can't locate object method "new" via package "Geo::Coder::Free::Display"

Check failure on line 25 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.38 on macos-14

Can't locate object method "new" via package "Geo::Coder::Free::Display"
config => { root_dir => Cwd::getcwd() }
);

# Test object creation
isa_ok($display, 'Geo::Coder::Free::Display', 'Object creation');

# Test retrieving the template path
ok($display->get_template_path({ modulepath => 'Geo/Coder/Free/Display/index' }), 'Template path retrieval');

# Test setting cookies
$display->set_cookie({ test_cookie => 'cookie_value' });
is_deeply(
$display->{_cookies},
{ test_cookie => 'cookie_value' },
'Set cookie successfully'
);

# Test generating HTTP headers
like($display->http(), qr/Content-Type: text\/html; charset=UTF-8/, 'HTTP headers generation');

like($display->html(), qr/<html/i, 'HTML generation');
like($display->as_string(), qr/html>/i, 'as_string');

# Simulate HTML generation (assuming template exists)
sub mock_template {
return "<html><body>Test Page</body></html>";
}
{
no warnings 'redefine';
*Geo::Coder::Free::Display::html = \&mock_template;

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.32 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.30 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.28 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.22 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.34 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.36 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.40 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.38 on macos-latest

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.22 on macos-14

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.28 on macos-14

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.34 on macos-14

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.30 on macos-14

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.32 on macos-14

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.36 on macos-14

Name "Geo::Coder::Free::Display::html" used only once: possible typo

Check failure on line 55 in t/display.t

View workflow job for this annotation

GitHub Actions / Perl 5.38 on macos-14

Name "Geo::Coder::Free::Display::html" used only once: possible typo
}
like($display->as_string({}), qr/Test Page/, 'HTML generation overriding html()');

0 comments on commit 64e9a1d

Please sign in to comment.