- $this->assertFileDb = dirname(__DIR__) . DIRECTORY_SEPARATOR .
- '..' . DIRECTORY_SEPARATOR .
- '..' . DIRECTORY_SEPARATOR .
- 'datasets' . DIRECTORY_SEPARATOR .
- 'ini' . DIRECTORY_SEPARATOR .
- 'assert_db.ini.php';
+ $this->assertFile = vfsStream::newFile('assert.ini.php')
+ ->at($this->root->getChild('test'))
+ ->setContent($this->replaceEnvironmentSettings($assertFile, false));
+ $this->assertFileDb = vfsStream::newFile('assert_db.ini.php')
+ ->at($this->root->getChild('test'))
+ ->setContent($this->replaceEnvironmentSettings($assertFile, true));
+ }
+
+ /**
+ * Replacing environment specific variables in the assertion file
+ *
+ * @param string $file The file to compare in later tests
+ * @param bool $withDb If true, db settings are replaced too
+ * @return string The file content
+ */
+ private function replaceEnvironmentSettings($file, $withDb)
+ {
+ $fileContent = file_get_contents($file);
+ $fileContent = str_replace("/usr/bin/php", trim(shell_exec('which php')), $fileContent);
+ if ($withDb) {
+ $fileContent = str_replace("hostname = \"\"", "hostname = \"" . $this->db_host . (!empty($this->db_port) ? ":" . $this->db_port : "") . "\"", $fileContent);
+ $fileContent = str_replace("username = \"\"", "username = \"" . $this->db_user . "\"", $fileContent);
+ $fileContent = str_replace("password = \"\"", "password = \"" . $this->db_pass . "\"", $fileContent);
+ $fileContent = str_replace("database = \"\"", "database = \"" . $this->db_data . "\"", $fileContent);
+ }
+ return $fileContent;