Change getMimeType and setMimeType to response->content_type.
This commit is contained in:
parent
e5adc07a05
commit
fd8f03a186
52 changed files with 138 additions and 175 deletions
|
|
@ -43,7 +43,7 @@ plan tests => 56; # Increment this number for each test you create
|
|||
# - user
|
||||
$session->user({ userId => 1 });
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -61,7 +61,7 @@ $session->request->setup_body({
|
|||
as => "xml",
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/xml', "Correct mime type (as => xml)" );
|
||||
is( $session->response->content_type, 'application/xml', "Correct mime type (as => xml)" );
|
||||
cmp_deeply(
|
||||
XML::Simple::XMLin( $response ),
|
||||
{
|
||||
|
|
@ -82,7 +82,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (as => json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (as => json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -99,7 +99,7 @@ $session->request->setup_body({
|
|||
firstName => 'Jake',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -121,7 +121,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=andy;o=block-e;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -153,7 +153,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=red;o=block-e;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxCreateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -183,7 +183,7 @@ is( $auth->getParams->{connectDN}, 'u=red;o=block-e;dc=shawshank;dc=me', "Auth p
|
|||
# - user
|
||||
$session->user({ userId => 1 });
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -201,7 +201,7 @@ $session->request->setup_body({
|
|||
as => "xml",
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/xml', "Correct mime type (as => xml)" );
|
||||
is( $session->response->content_type, 'application/xml', "Correct mime type (as => xml)" );
|
||||
cmp_deeply(
|
||||
XML::Simple::XMLin( $response ),
|
||||
{
|
||||
|
|
@ -222,7 +222,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (as => json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (as => json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -241,7 +241,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -263,7 +263,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=rich;o=escapee;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -294,7 +294,7 @@ $session->request->setup_body({
|
|||
'auth:LDAP:connectDN' => 'u=red;o=parollee;dc=shawshank;dc=me',
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxUpdateUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json" );
|
||||
$responseObj = JSON->new->decode( $response );
|
||||
cmp_deeply(
|
||||
$responseObj,
|
||||
|
|
@ -323,7 +323,7 @@ is( $auth->getParams->{connectDN}, 'u=red;o=parollee;dc=shawshank;dc=me', "Auth
|
|||
# - user
|
||||
$session->user({ userId => 1 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -341,7 +341,7 @@ $session->request->setup_body({
|
|||
as => "xml",
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/xml', "Correct mime type (as => xml)" );
|
||||
is( $session->response->content_type, 'application/xml', "Correct mime type (as => xml)" );
|
||||
cmp_deeply(
|
||||
XML::Simple::XMLin( $response ),
|
||||
{
|
||||
|
|
@ -360,7 +360,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (as => json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (as => json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -377,7 +377,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -394,7 +394,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -411,7 +411,7 @@ $session->request->setup_body({
|
|||
});
|
||||
$session->user({ userId => 3 });
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', "Correct mime type (default: json)" );
|
||||
is( $session->response->content_type, 'application/json', "Correct mime type (default: json)" );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -427,7 +427,7 @@ $session->request->setup_body({
|
|||
userId => $userAndy->getId,
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', 'Correct mime type (default: json)' );
|
||||
is( $session->response->content_type, 'application/json', 'Correct mime type (default: json)' );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
@ -441,7 +441,7 @@ $session->request->setup_body({
|
|||
userId => $userRed->getId,
|
||||
});
|
||||
$response = WebGUI::Operation::User::www_ajaxDeleteUser( $session );
|
||||
is( $session->http->getMimeType, 'application/json', 'Correct mime type (default: json)' );
|
||||
is( $session->response->content_type, 'application/json', 'Correct mime type (default: json)' );
|
||||
cmp_deeply(
|
||||
JSON->new->decode( $response ),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ use Data::Dumper;
|
|||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
plan tests => 46;
|
||||
plan tests => 44;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -55,19 +55,6 @@ $response->status('302');
|
|||
ok($http->isRedirect, '... 302 is too');
|
||||
$response->status('200');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# setMimeType, getMimeType
|
||||
#
|
||||
####################################################
|
||||
|
||||
$http->setMimeType('');
|
||||
is($http->getMimeType, 'text/html; charset=UTF-8', 'set/get MimeType: default is text/html');
|
||||
|
||||
$http->setMimeType('image/jpeg');
|
||||
is($http->getMimeType, 'image/jpeg', 'set/get MimeType: set specific type and get it');
|
||||
$http->setMimeType('');
|
||||
|
||||
####################################################
|
||||
#
|
||||
# setStreamedFile, getStreamedFile
|
||||
|
|
@ -91,13 +78,13 @@ $http->setStreamedFile('');
|
|||
|
||||
$http->setFilename('foo.bin');
|
||||
is($http->getFilename, 'foo.bin', 'set/get Filename: filename passed');
|
||||
is($http->getMimeType(), 'application/octet-stream', 'set/get Filename: default mime type is octet/stream');
|
||||
is($response->content_type(), 'application/octet-stream', 'set/get Filename: default mime type is octet/stream');
|
||||
|
||||
$http->setFilename('foo.txt','text/plain');
|
||||
is($http->getFilename, 'foo.txt', 'set/get Filename: filename set');
|
||||
is($http->getMimeType(), 'text/plain', 'set/get Filename: mime type set');
|
||||
is($response->content_type(), 'text/plain', 'set/get Filename: mime type set');
|
||||
$http->setFilename('');
|
||||
$http->setMimeType('');
|
||||
$response->content_type('');
|
||||
|
||||
####################################################
|
||||
#
|
||||
|
|
@ -201,6 +188,7 @@ is($http->sendHeader, undef, 'sendHeader returns undef when no request object is
|
|||
headers_out($session1->response->headers),
|
||||
{
|
||||
'Location' => '/here/there',
|
||||
'Content-Type' => 'text/html; charset=UTF-8',
|
||||
},
|
||||
'... location set'
|
||||
);
|
||||
|
|
@ -220,7 +208,6 @@ is($http->sendHeader, undef, 'sendHeader returns undef when no request object is
|
|||
my $http = $session->http;
|
||||
my $response = $session->response;
|
||||
$response->status(200);
|
||||
$http->setMimeType('');
|
||||
$session->request->protocol('');
|
||||
$http->setLastModified(1200);
|
||||
|
||||
|
|
@ -255,7 +242,7 @@ is($http->sendHeader, undef, 'sendHeader returns undef when no request object is
|
|||
my $http = $session->http;
|
||||
my $response = $session->response;
|
||||
$http->setFilename('image.png');
|
||||
$http->setMimeType('image/png');
|
||||
$response->content_type('image/png');
|
||||
$http->sendHeader();
|
||||
is($response->headers->content_type, 'image/png', 'sendHeader: mimetype');
|
||||
cmp_deeply(
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ like($response->body->[-1], qr/3\Z/, '... macro processing');
|
|||
$output->print('^#;', 1);
|
||||
like($response->body->[-1], qr/\^#;\Z/, '... macro processing skipped due to flag');
|
||||
|
||||
$session->http->setMimeType('application/json');
|
||||
$session->response->content_type('application/json');
|
||||
$output->print('^#;');
|
||||
like($response->body->[-1], qr/\^#;\Z/, '... macro processing skipped due to mime type');
|
||||
|
||||
$session->http->setMimeType('');
|
||||
$session->response->content_type('');
|
||||
$output->setHandle($otherHandle);
|
||||
$output->print('New content');
|
||||
is($otherHandleBuffer, 'New content', '... set to explicit handle');
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ is($taxer->getTaxRate( $taxableDonation, $taxFreeAddress ), 0, 'calculate: simpl
|
|||
$session->user({userId=>3});
|
||||
my $json = $taxer->www_getTaxesAsJson();
|
||||
ok($json, 'www_getTaxesAsJson returned something');
|
||||
is($session->http->getMimeType, 'application/json', 'MIME type set to application/json');
|
||||
is($session->response->content_type, 'application/json', 'MIME type set to application/json');
|
||||
my $jsonTax = JSON::from_json($json);
|
||||
cmp_deeply(
|
||||
$jsonTax,
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ is(scalar @{$transaction->getItems}, 0, "can delete items");
|
|||
$session->user({userId=>3});
|
||||
my $json = WebGUI::Shop::Transaction->www_getTransactionsAsJson($session);
|
||||
ok($json, 'www_getTransactionsAsJson returned something');
|
||||
is($session->http->getMimeType, 'application/json', 'MIME type set to application/json');
|
||||
is($session->response->content_type, 'application/json', 'MIME type set to application/json');
|
||||
my $jsonTransactions = JSON::from_json($json);
|
||||
cmp_deeply(
|
||||
$jsonTransactions,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue