Apache2-Translation

 view release on metacpan or  search on metacpan

t/011directives.t  view on Meta::CPAN

  ok t_cmp GET_RC( '/cgi2/script.pl' ), 500, n '/cgi2/script.pl';

  t_start_error_log_watch;
  my $body=GET_BODY( '/cgi3/script.pl' );
  my @lines=t_finish_error_log_watch;
  if(grep /\.htaccess: Option ExecCGI not allowed here/, @lines) {
    warn "\n\n# WARNING: Your httpd is buggy.\n# See http://www.gossamer-threads.com/lists/apache/dev/327770#327770\n\n";
    ok 1, n '/cgi3/script.pl';
  } else {
    ok t_cmp $body, qr!^CGI/!, n '/cgi3/script.pl';
  }
}

my $resp=GET( '/error' );
ok t_cmp $resp->code, 302, n '/error: code==302';
ok t_cmp $resp->header('Location'),
         'http://'.Apache::TestRequest::hostport.'/tsthnd',
         n '/error: Location==http://'.Apache::TestRequest::hostport.'/tsthnd';

$resp=GET( '/not_found' );
ok t_cmp $resp->code, 302, n '/not_found: code==302';
ok t_cmp $resp->header('Location'),
         'http://'.Apache::TestRequest::hostport.'/tsthnd',
         n '/not_found: Location==http://'.Apache::TestRequest::hostport.'/tsthnd';

$resp=GET( '/redr/1' );
ok t_cmp $resp->code, 302, n '/redr/1: code==302';
ok t_cmp $resp->header('Location'),
         'http://'.Apache::TestRequest::hostport.'/redr/otto/1',
         n '/redr/1: Location==http://'.Apache::TestRequest::hostport.'/redr/otto/1';

$resp=GET( '/redr/2' );
ok t_cmp $resp->code, 302, n '/redr/2: code==302';
ok t_cmp $resp->header('Location'),
         'http://'.Apache::TestRequest::hostport.'/otto/2',
         n '/redr/2: Location==http://'.Apache::TestRequest::hostport.'/otto/2';

ok t_cmp GET_BODY( '/call' ), '1/', n '/call';
ok t_cmp GET_BODY( '/call2' ), '/2', n '/call2';

ok t_cmp GET_BODY( '/fixup' ), '1 2 3', n '/fixup';

$resp=GET( '/html' );
ok t_cmp $resp->content, 'HTML', n '/html body';
ok t_cmp $resp->header('Content-Type'), 'text/html', n '/html content_type';

$resp=GET( '/txt0' );
ok t_cmp $resp->content, 'TXT', n '/txt0 body';
ok t_cmp $resp->header('Content-Type'), 'text/plain', n '/txt0 content_type';

$resp=GET( '/txt1' );
ok t_cmp $resp->content, 'TXT', n '/txt1 body';
ok t_cmp $resp->header('Content-Type'), 'text/plain', n '/txt1 content_type';

SKIP: {
  skip "Need Linux::Smaps to report meminfo", 0 unless( need_module( 'Linux::Smaps' ) );
  t_debug GET_BODY( '/minfo' );
}

SKIP: {
  skip "Need JSON::XS or YAML to test Apache2::Translation::Config", 1
    unless( need_module( 'JSON::XS' ) or need_module( 'YAML' ) );
  my $text=GET_BODY( '/econf' );

  my $x;
  unless( eval 'require JSON::XS' and
          $x=eval {JSON::XS::decode_json($text)} ) {
    eval 'require YAML' and $x=eval {YAML::Load($text)};
  }

  ok( t_cmp $x,
      {
       TranslationProvider  => [
				'DB',
				database  => $db,
				user      => $user,
				password  => $pw,
				table     => 'trans',
				id        => 'id',
				key       => 'xkey',
				uri       => 'xuri',
				block     => 'xblock',
				order     => 'xorder',
				action    => 'xaction',
				cachetbl  => 'cache',
				cachecol  => 'v',
				singleton => '1'
			       ],
       TranslationKey       => 'default',
       TranslationEvalCache => 'unlimited'
      },
      n 'Apache2::Translation::Config' );
}

SKIP: {
  skip "Need YAML to test Apache2::Translation::Config in YAML mode", 1
    unless( need_module( 'YAML' ) );
  my $text=GET_BODY( '/econf?Yaml' );

  my $x;
  unless( eval 'require JSON::XS' and
          $x=eval {JSON::XS::decode_json($text)} ) {
    eval 'require YAML' and $x=eval {YAML::Load($text)};
  }

  ok( t_cmp $x,
      {
       TranslationProvider  => [
				'DB',
				database  => $db,
				user      => $user,
				password  => $pw,
				table     => 'trans',
				id        => 'id',
				key       => 'xkey',
				uri       => 'xuri',
				block     => 'xblock',
				order     => 'xorder',
				action    => 'xaction',
				cachetbl  => 'cache',
				cachecol  => 'v',
				singleton => '1'
			       ],
       TranslationKey       => 'default',
       TranslationEvalCache => 'unlimited'
      },
      n 'Apache2::Translation::Config' );
}

SKIP: {
  skip "Need Linux::Smaps to report meminfo", 0 unless( need_module( 'Linux::Smaps' ) );
  t_debug GET_BODY( '/minfo' );
}

$dbh->disconnect;



( run in 1.972 second using v1.01-cache-2.11-cpan-39bf76dae61 )