📄 testconfigphp.pm
字号:
# Copyright 2001-2005 The Apache Software Foundation or its licensors, as# applicable.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.#package Apache::TestConfigPHP;#things specific to phpuse strict;use warnings FATAL => 'all';use File::Spec::Functions qw(catfile splitdir abs2rel);use File::Find qw(finddepth);use Apache::TestTrace;use Apache::TestRequest;use Apache::TestConfig;use Apache::TestConfigPerl;use Config;@Apache::TestConfigPHP::ISA = qw(Apache::TestConfig);my ($php_ini, $test_more);{ # __DATA__ contains both php.ini and test-more.php local $/ = "END_OF_FILE\n"; $php_ini = <DATA>; chomp $php_ini; $test_more = <DATA>; chomp $test_more;}sub new { return shift->SUPER::new(@_);}my %warn_style = ( html => sub { "<!-- @_ -->" }, c => sub { "/* @_ */" }, ini => sub { join '', grep {s/^/; /gm} @_ }, php => sub { join '', "<?php\n", grep {s/^/# /gm} @_ }, default => sub { join '', grep {s/^/\# /gm} @_ },);my %file_ext = ( map({$_ => 'html'} qw(htm html)), map({$_ => 'c' } qw(c h)), map({$_ => 'ini' } qw(ini)), map({$_ => 'php' } qw(php)),);sub warn_style_sub_ref { my ($self, $filename) = @_; my $ext = $self->filename_ext($filename); return $warn_style{ $file_ext{$ext} || 'default' };}sub configure_php_tests_pick { my($self, $entries) = @_; for my $subdir (qw(Response)) { my $dir = catfile $self->{vars}->{t_dir}, lc $subdir; next unless -d $dir; finddepth(sub { return unless /\.php$/; my $file = catfile $File::Find::dir, $_; my $module = abs2rel $file, $dir; my $status = $self->run_apache_test_config_scan($file); push @$entries, [$file, $module, $subdir, $status]; }, $dir); }}sub write_php_test { my($self, $location, $test) = @_; (my $path = $location) =~ s/test//i; (my $file = $test) =~ s/php$/t/i; my $dir = catfile $self->{vars}->{t_dir}, lc $path; my $t = catfile $dir, $file; return if -e $t; unless (-e $t) { $self->gendir($dir); my $fh = $self->genfile($t); print $fh <<EOF;use Apache::TestRequest 'GET_BODY_ASSERT';print GET_BODY_ASSERT "/$location/$test";EOF close $fh or die "close $t: $!"; } # write out an all.t file for the directory # that will skip running all PHP test unless have_php my $all = catfile $dir, 'all.t'; unless (-e $all) { my $fh = $self->genfile($all); print $fh <<EOF;use strict;use warnings FATAL => 'all';use Apache::Test;# skip all tests in this directory unless a php module is enabledplan tests => 1, need_php;ok 1;EOF }}sub configure_php_inc { my $self = shift; my $serverroot = $self->{vars}->{serverroot}; my $path = catfile $serverroot, 'conf'; # make sure that require() or include() calls can find # the generated test-more.php without using absolute paths my $cfg = { php_value => "include_path $path", }; $self->postamble(IfModule => $self->{vars}->{php_module}, $cfg); # give test-more.php access to the ServerRoot directive $self->postamble("SetEnv SERVER_ROOT $serverroot\n");}sub configure_php_functions { my $self = shift; my $dir = catfile $self->{vars}->{serverroot}, 'conf'; my $file = catfile $dir, 'test-more.php'; $self->gendir($dir); my $fh = $self->genfile($file); print $fh $test_more; close $fh or die "close $file: $!"; $self->clean_add_file($file);}sub configure_php_ini { my $self = shift; my $dir = catfile $self->{vars}->{serverroot}, 'conf'; my $file = catfile $dir, 'php.ini'; my $log = catfile $self->{vars}->{t_logs}, 'error_log'; $self->gendir($dir); my $fh = $self->genfile($file); $php_ini =~ s/\@error_log\@/error_log $log/; print $fh $php_ini; close $fh or die "close $file: $!"; $self->clean_add_file($file);}sub configure_php_tests { my $self = shift; my @entries = (); $self->configure_php_tests_pick(\@entries); $self->configure_pm_tests_sort(\@entries); my %seen = (); for my $entry (@entries) { my ($file, $module, $subdir, $status) = @$entry; my @args = (); my $directives = $self->add_module_config($file, \@args); my @parts = splitdir $file; my $test = pop @parts; my $location = $parts[-1]; debug "configuring PHP test file $file"; if ($directives->{noautoconfig}) { $self->postamble(""); # which adds "\n" } else { unless ($seen{$location}++) { $self->postamble(Alias => [ catfile('', $parts[-1]), catfile(@parts) ]); my @args = (AddType => 'application/x-httpd-php .php'); $self->postamble(Location => "/$location", \@args); } } $self->write_php_test($location, $test); }}1;__DATA__; This is php.ini-recommended from php 5.0.2,; used in place of your locally installed php.ini file; as part of the pristine environment Apache-Test creates; for you;; exceptions to php.ini-recommended are as follows:display_startup_errors = Onhtml_errors = Off@error_log@output_buffering = Off; the rest of php.ini-recommended, unaltered, save for; some tidying like the removal of comments and blank lines[PHP]engine = Onzend.ze1_compatibility_mode = Offshort_open_tag = Onasp_tags = Offprecision = 14y2k_compliance = On;output_buffering = 4096zlib.output_compression = Offimplicit_flush = Offunserialize_callback_func=serialize_precision = 100allow_call_time_pass_reference = Offsafe_mode = Offsafe_mode_gid = Offsafe_mode_include_dir =safe_mode_exec_dir =safe_mode_allowed_env_vars = PHP_safe_mode_protected_env_vars = LD_LIBRARY_PATHdisable_functions =disable_classes =expose_php = Onmax_execution_time = 30max_input_time = 60memory_limit = 8Merror_reporting = E_ALLdisplay_errors = Off;display_startup_errors = Offlog_errors = Onlog_errors_max_len = 1024ignore_repeated_errors = Offignore_repeated_source = Offreport_memleaks = Ontrack_errors = Offvariables_order = "GPCS"register_globals = Offregister_long_arrays = Offregister_argc_argv = Offpost_max_size = 8Mmagic_quotes_gpc = Offmagic_quotes_runtime = Offmagic_quotes_sybase = Offauto_prepend_file =auto_append_file =default_mimetype = "text/html"doc_root =user_dir =extension_dir = "./"enable_dl = Onfile_uploads = Onupload_max_filesize = 2Mallow_url_fopen = Ondefault_socket_timeout = 60[Syslog]define_syslog_variables = Off[mail function]SMTP = localhostsmtp_port = 25[SQL]sql.safe_mode = Off[ODBC]odbc.allow_persistent = Onodbc.check_persistent = Onodbc.max_persistent = -1odbc.max_links = -1odbc.defaultlrl = 4096odbc.defaultbinmode = 1[MySQL]mysql.allow_persistent = Onmysql.max_persistent = -1mysql.max_links = -1mysql.default_port =mysql.default_socket =mysql.default_host =mysql.default_user =mysql.default_password =mysql.connect_timeout = 60mysql.trace_mode = Off[MySQLI]mysqli.max_links = -1mysqli.default_port = 3306mysqli.default_socket =mysqli.default_host =mysqli.default_user =mysqli.default_password =mysqli.reconnect = Off[mSQL]msql.allow_persistent = Onmsql.max_persistent = -1msql.max_links = -1[PostgresSQL]pgsql.allow_persistent = Onpgsql.auto_reset_persistent = Offpgsql.max_persistent = -1pgsql.max_links = -1pgsql.ignore_notice = 0pgsql.log_notice = 0[Sybase]sybase.allow_persistent = Onsybase.max_persistent = -1sybase.max_links = -1sybase.min_error_severity = 10sybase.min_message_severity = 10sybase.compatability_mode = Off[Sybase-CT]sybct.allow_persistent = Onsybct.max_persistent = -1sybct.max_links = -1sybct.min_server_severity = 10sybct.min_client_severity = 10[dbx]dbx.colnames_case = "lowercase"[bcmath]bcmath.scale = 0[browscap][Informix]ifx.default_host =ifx.default_user =ifx.default_password =ifx.allow_persistent = Onifx.max_persistent = -1ifx.max_links = -1ifx.textasvarchar = 0ifx.byteasvarchar = 0ifx.charasvarchar = 0ifx.blobinfile = 0ifx.nullformat = 0[Session]session.save_handler = filessession.use_cookies = 1session.name = PHPSESSIDsession.auto_start = 0session.cookie_lifetime = 0session.cookie_path = /session.cookie_domain =session.serialize_handler = phpsession.gc_probability = 1session.gc_divisor = 1000session.gc_maxlifetime = 1440session.bug_compat_42 = 0session.bug_compat_warn = 1session.referer_check =session.entropy_length = 0session.entropy_file =session.cache_limiter = nocachesession.cache_expire = 180session.use_trans_sid = 0session.hash_function = 0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -