Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9866d032

Von Sven Schöling vor etwa 1 Jahr hinzugefügt

  • ID 9866d032bba814a0db0deb802ca65bfab2c3350e
  • Vorgänger 5f1d7544
  • Nachfolger ea08b7df

tests: t/fx/aptransactions.t auf t/Support/Integration.pm umgeschrieben

Unterschiede anzeigen:

t/fxtransaction/ap_transactions.t
use HTML::Query;
use Support::TestSetup;
use Support::Integration;
my $part;
my $vendor;
......
}
package MockDispatcher {
sub end_request { die "END_OF_REQUEST" }
};
$::dispatcher = bless { }, "MockDispatcher";
# make a pseudo request to an old bin/mozilla style entry point
# captures STDOUT, STDERR and the return values of the called action
#
# the given form should be set up like it would be in Dispatcher after read_cgi_input
sub make_request {
my ($script, $form, $action) = @_;
my ($out, $err, @ret);
package main {
local $SIG{__WARN__} = sub {
# ignore spurious warnings, TAP::Harness calls this warnings enabled
};
require "bin/mozilla/$script.pl";
open(my $out_fh, '>', \$out) or die;
open(my $err_fh, '>', \$err) or die;
local *STDOUT = $out_fh;
local *STDERR = $err_fh;
local $::form = Form->new;
$::form->{$_} = $form->{$_} for keys %$form;
$::form->{script} = $script.'.pl'; # usually set by dispatcher, needed for checks in update_exchangerate
local $ENV{REQUEST_URI} = "http://localhost/$script.pl"; # needed for Form::redirect_header
no strict "refs";
eval {
no warnings;
@ret = &{ "::$action" }();
1;
} or do { my $err = $@;
die unless $err =~ /^END_OF_REQUEST/;
@ret = (1);
}
}
return ($out, $err, @ret);
}
sub form_from_html {
my ($html) = @_;
my $q = HTML::Query->new(text => $html);
my %form;
for my $input ($q->query('#form input')->get_elements()) {
next if !$input->attr('name') || $input->attr('disabled');
$form{ $input->attr('name') } = $input->attr('value') // "";