-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
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 GitHub Actions / Perl 5.32 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.30 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.28 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.22 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.34 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.36 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.40 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.38 on macos-latest
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.22 on macos-14
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.28 on macos-14
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.34 on macos-14
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.30 on macos-14
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.32 on macos-14
Check failure on line 25 in t/display.t GitHub Actions / Perl 5.36 on macos-14
|
||
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 GitHub Actions / Perl 5.32 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.30 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.28 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.22 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.34 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.36 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.40 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.38 on macos-latest
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.22 on macos-14
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.28 on macos-14
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.34 on macos-14
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.30 on macos-14
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.32 on macos-14
Check failure on line 55 in t/display.t GitHub Actions / Perl 5.36 on macos-14
|
||
} | ||
like($display->as_string({}), qr/Test Page/, 'HTML generation overriding html()'); |