Update this test for Plack.
This commit is contained in:
parent
caacf34d05
commit
3593001869
1 changed files with 15 additions and 15 deletions
|
|
@ -16,11 +16,10 @@ use WebGUI::Test;
|
|||
use WebGUI::Session;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
my $skip_tests = 8;
|
||||
my $num_tests = 1 + $skip_tests;
|
||||
|
||||
plan tests => $num_tests;
|
||||
plan tests => 9;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -30,37 +29,38 @@ my $output = $session->output;
|
|||
|
||||
isa_ok($output, 'WebGUI::Session::Output', 'session has correct object type');
|
||||
|
||||
my $recentVersion = $^V gt v5.8;
|
||||
|
||||
|
||||
my $otherHandleBuffer;
|
||||
open my $otherHandle, '>', \$otherHandleBuffer or die "Unable to create second filehandle: $!\n";
|
||||
|
||||
my $request = $session->request;
|
||||
my $response = $session->response;
|
||||
|
||||
$output->setHandle(undef);
|
||||
is($output->{_handle}, undef, 'setHandle: handle cleared');
|
||||
|
||||
$output->print('Hello STDOUT');
|
||||
is($request->get_output, 'Hello STDOUT', 'print with no handle goes to STDOUT');
|
||||
is($response->body->[-1], 'Hello STDOUT', 'print with no handle goes to STDOUT');
|
||||
|
||||
$output->print(' more stuff');
|
||||
is($request->get_output, 'Hello STDOUT more stuff', 'print: tied variables accumulate');
|
||||
cmp_deeply(
|
||||
$response->body,
|
||||
['Hello STDOUT', ' more stuff'],
|
||||
'... tied variables accumulate'
|
||||
);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$output->print('^#;');
|
||||
like($request->get_output, qr/3\Z/, 'print: macro processing');
|
||||
like($response->body->[-1], qr/3\Z/, '... macro processing');
|
||||
|
||||
$output->print('^#;', 1);
|
||||
like($request->get_output, qr/\^#;\Z/, 'print: macro processing skipped');
|
||||
like($response->body->[-1], qr/\^#;\Z/, '... macro processing skipped due to flag');
|
||||
|
||||
$session->http->setMimeType('application/json');
|
||||
$output->print('^#;');
|
||||
like($request->get_output, qr/\^#;\Z/, 'print: macro processing skipped');
|
||||
like($response->body->[-1], qr/\^#;\Z/, '... macro processing skipped due to mime type');
|
||||
|
||||
$session->http->setMimeType('');
|
||||
$output->setHandle($otherHandle);
|
||||
$output->print('New content');
|
||||
is($otherHandleBuffer, 'New content', 'print: set to explicit handle');
|
||||
unlike($request->get_output, qr/New content\Z/, 'print: no leakage back to STDOUT');
|
||||
is($otherHandleBuffer, 'New content', '... set to explicit handle');
|
||||
unlike($response->body->[-1], qr/New content\Z/, '... no leakage back to STDOUT');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue