X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c0b530184e94d6c61ea15b3c75bd66f51fe958eb..d1f44c84d990f57982854c6a4716c0f233f45bca:/t/file/filesystem.t?ds=inline diff --git a/t/file/filesystem.t b/t/file/filesystem.t index aa19ac714..d35a95faf 100644 --- a/t/file/filesystem.t +++ b/t/file/filesystem.t @@ -1,5 +1,5 @@ use strict; -use Test::More tests => 11; +use Test::More tests => 14; use lib 't'; @@ -15,10 +15,10 @@ my $temp_dir = File::Temp::tempdir("kivi-t-file-filesystem.XXXXXX", TMPDIR => my $storage_dir = "$temp_dir/storage"; mkdir($storage_dir) || die $!; - -my $db = SL::DB::Object->new->db; -$db->dbh->do("UPDATE defaults SET doc_files = 't'"); -$db->dbh->do("UPDATE defaults SET doc_files_rootpath = ?", undef, $storage_dir); +{ +local $::lx_office_conf{paths}->{document_path} = $storage_dir; +$::instance_conf->data; +local $::instance_conf->{data}{doc_files} = 1; my $scannerfile = "${temp_dir}/f2"; @@ -54,31 +54,53 @@ ok( $$content5 eq 'inhalt3 new version' ,"file has right actual $content5 = $file6[1]->get_content; ok( $$content5 eq 'inhalt3 created' ,"file has right old content"); -print "\n\nController:\n"; +#print "\n\nController Test:\n"; # now test controller #$::form->{object_id} = 1; #$::form->{object_type}= 'sales_order'; #$::form->{file_type} = 'document'; + +my $output; +open(my $outputFH, '>', \$output) or die; # This shouldn't fail +my $oldFH = select $outputFH; + $::form->{id} = $file1->id; -print "id=".$::form->{id}."\n"; use SL::Controller::File; SL::Controller::File->action_download(); + +select $oldFH; +close $outputFH; +my @lines = split "\n" , $output; +ok($lines[4] eq 'inhalt1 uploaded' ,"controller download has correct content"); + +#some controller checks $::form->{object_id} = 12345678; $::form->{object_type} = undef; +my $result='xx1'; eval { SL::Controller::File->check_object_params(); + $result='yy1'; 1; } or do { - print $@; + $result=$@; }; -$::form->{object_type} ='xx'; -$::form->{file_type} ='yy'; +$result = substr($result,0,14); +#print $result."\n"; +ok($result eq "No object type","correct error 'No object type'"); + +$::form->{object_type} ='sales_order'; +$::form->{file_type} =''; +$result='xx2'; eval { SL::Controller::File->check_object_params(); + $result='yy2'; 1; } or do { - print $@; + $result=$@; }; +$result = substr($result,0,12); +#print $result."\n"; +ok($result eq "No file type","correct error 'No file type'"); clear_up(); done_testing; @@ -91,6 +113,8 @@ sub clear_up { }; } +} + sub reset_state { my %params = @_;