public function testWriteWithRuntimeValues() { $_php = new M3_Util_PhpSettings('PhpSettingsTestCase4.php'); $_data = array(M3_Util_PhpSettings::UNPARSED . '0' => "<?php\n", 'GLOBALS[\'g1\']' => 'gone', 'GLOBALS[\'g2\']' => 'gtwo', 'GLOBALS[\'str1\']' => '"string here"', 'GLOBALS[\'str2\']' => '\'another string\'', M3_Util_PhpSettings::UNPARSED . '2' => "?>\n"); $GLOBALS['g1'] = '"GONE REPLACEMENT"'; $GLOBALS['str1'] = '"STR1 REPLACEMENT"'; $_php->writePhpFileWithRuntimeValues($_data); $_contents = file_get_contents($_php->getConfigurationPathName()); $this->assertEquals(1, preg_match('/\\n\\$GLOBALS\\[\'g1\'\\]="GONE REPLACEMENT";\\n/', $_contents), "bad 1"); $this->assertEquals(1, preg_match('/\\n\\$GLOBALS\\[\'g2\'\\]=;\\n/', $_contents), "bad 2"); $this->assertEquals(1, preg_match('/\\n\\$GLOBALS\\[\'str1\'\\]="STR1 REPLACEMENT";\\n/', $_contents), "bad 3"); $this->assertEquals(1, preg_match('/\\n\\$GLOBALS\\[\'str2\'\\]=;\\n/', $_contents), "bad 4"); $_php->readPhpFile($_readData); $this->assertArrayHasKey('GLOBALS[\'g1\']', $_readData); $this->assertArrayHasKey('GLOBALS[\'g2\']', $_readData); $this->assertArrayHasKey('GLOBALS[\'str1\']', $_readData); $this->assertArrayHasKey('GLOBALS[\'str2\']', $_readData); // remove test file unlink($_php->getConfigurationPathName()); }