[Http-webtest-commits] HTTP-WebTest-Recorder/t 03-actions.t,1.9,1.10
Brought to you by:
m_ilya,
richardanderson
From: Ilya M. <m_...@us...> - 2003-04-22 23:01:37
|
Update of /cvsroot/http-webtest/HTTP-WebTest-Recorder/t In directory sc8-pr-cvs1:/tmp/cvs-serv28703/t Modified Files: 03-actions.t Log Message: Added tests for css_action() and render_template_action() Index: 03-actions.t =================================================================== RCS file: /cvsroot/http-webtest/HTTP-WebTest-Recorder/t/03-actions.t,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** 03-actions.t 22 Apr 2003 22:18:08 -0000 1.9 --- 03-actions.t 22 Apr 2003 23:01:34 -0000 1.10 *************** *** 6,10 **** use HTTP::Status; ! use Test::More tests => 42; # get test template files directory included in search path --- 6,10 ---- use HTTP::Status; ! use Test::More tests => 55; # get test template files directory included in search path *************** *** 227,228 **** --- 227,294 ---- } + + # test css_action() + { + css_action($CONTROLLER); + is($CONTROLLER->heap->{response}->header('Content-Type'), 'text/css', + 'Test if content type is set correctly'); + } + + # test render_template_action() with view which does exist + { + $CONTROLLER->heap({}); + $CONTROLLER->heap->{view} = 'testme'; + $CONTROLLER->heap->{var} = 'xxx'; + $CONTROLLER->heap->{response} = HTTP::Response->new(RC_OK); + render_template_action($CONTROLLER); + is($CONTROLLER->heap->{response}->code, RC_OK, + 'Test if response code is ok'); + is($CONTROLLER->heap->{response}->header('Content-Type'), 'text/html', + 'Test if content type is set correctly'); + like($CONTROLLER->heap->{response}->content, qr/VAR = xxx/, + 'Test if content has rendered template'); + + $CONTROLLER->heap({}); + $CONTROLLER->heap->{view} = 'testme'; + $CONTROLLER->heap->{var} = 'xxx'; + $CONTROLLER->heap->{response} = HTTP::Response->new(RC_OK); + $CONTROLLER->heap->{response}->header('Content-Type' => 'text/css'); + render_template_action($CONTROLLER); + is($CONTROLLER->heap->{response}->code, RC_OK, + 'Test if response code is ok'); + is($CONTROLLER->heap->{response}->header('Content-Type'), 'text/css', + 'Test if content render_template_action() does not ' . + 'override already set content type'); + like($CONTROLLER->heap->{response}->content, qr/VAR = xxx/, + 'Test if content has rendered template'); + } + + # test render_template_action() with view which doesn't exist + { + $CONTROLLER->heap({}); + $CONTROLLER->heap->{view} = 'notfound'; + $CONTROLLER->heap->{var} = 'xxx'; + $CONTROLLER->heap->{response} = HTTP::Response->new(RC_OK); + render_template_action($CONTROLLER); + is($CONTROLLER->heap->{response}->code, RC_NOT_FOUND, + 'Test if response code is not found'); + is($CONTROLLER->heap->{response}->header('Content-Type'), 'text/plain', + 'Test if content type is set correctly'); + is($CONTROLLER->heap->{response}->content, 'Not Found', + 'Test if content contains error message'); + } + + # test render_template_action() with view which crashes + { + $CONTROLLER->heap({}); + $CONTROLLER->heap->{view} = 'testcrash'; + $CONTROLLER->heap->{var} = 'xxx'; + $CONTROLLER->heap->{response} = HTTP::Response->new(RC_OK); + render_template_action($CONTROLLER); + is($CONTROLLER->heap->{response}->code, RC_INTERNAL_SERVER_ERROR, + 'Test if response code is internal error'); + is($CONTROLLER->heap->{response}->header('Content-Type'), 'text/plain', + 'Test if content type is set correctly'); + like($CONTROLLER->heap->{response}->content, qr/file error - parse error/, + 'Test if content contains error message'); + } |