3 class PHPT_Section_INI
extends PHPT_Section_ModifiableAbstract
implements PHPT_Section_RunnableBefore
5 private $_default_values = array(
6 'output_handler' => '',
9 'disable_functions' => '',
10 'output_buffering' => 'Off',
11 'display_errors' => '1',
14 'track_errors' => '1',
15 'report_memleaks' => '0',
16 'report_zend_debug' => '0',
18 'docref_ext' => '.html',
19 'error_prepend_string' => '',
20 'error_append_string' => '',
21 'auto_prepend_file' => '',
22 'auto_append_file' => '',
23 'magic_quotes_runtime' => '0',
24 'xdebug.default_enable' => '0',
25 'allow_url_fopen' => '1',
28 public $data = array();
29 private $_raw_data = null;
30 private $_case = null;
32 public function __construct($data = '')
34 parent
::__construct($data);
35 $this->_raw_data
= $data;
38 public function run(PHPT_Case
$case)
42 if (!empty($this->_raw_data
)) {
43 $this->data
= $this->_loadFromFileAndParseIni($this->_raw_data
);
44 } elseif (file_exists($this->_getPhpIni($case))) {
45 $this->data
= $this->_loadFromFileAndParseIni($this->_getPhpIni($case));
48 if (isset(PHPT_Registry
::getInstance()->opts
['ini'])) {
49 $this->data
= array_merge(
50 $this->_parseIni(PHPT_Registry
::getInstance()->opts
['ini'], ','),
55 $this->data
= array_merge($this->data
, $this->_default_values
);
58 public function getPriority()
63 private function _loadFromFileAndParseIni($data, $separator = PHP_EOL
)
66 $data = file_get_contents($data);
68 $php = new PHPT_Util_Code($data);
69 if ($php->isValid()) {
70 $data = $php->runAsFile($this->_case
->filename
. '.ini');
72 $data = file_get_contents($data);
76 return $this->_parseIni($data, $separator);
79 private function _parseIni($raw_data, $separator = PHP_EOL
)
82 $lines = explode($separator, $raw_data);
83 foreach ($lines as $line) {
84 $pair = explode('=', $line, 2);
85 $return[trim($pair[0])] = trim($pair[1]);
90 private function _getPhpIni(PHPT_Case
$case) {
91 return dirname($case->filename
) . '/php.ini';
94 public function __toString()
97 foreach ($this->data
as $key => $value) {
98 if (!empty($string)) {
101 $string .= "-d \"{$key}={$value}\"";