]> git.mxchange.org Git - friendica.git/commitdiff
Add .htconfig.php in test setUp
authorHypolite Petovan <mrpetovan@gmail.com>
Tue, 3 Jul 2018 03:10:33 +0000 (23:10 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Tue, 3 Jul 2018 04:02:02 +0000 (00:02 -0400)
tests/DatabaseTest.php

index 12150932c9dba2a6da019514d2284da17f53f010..6edd45e575f257f3e584d8b907aca607bf20e3eb 100644 (file)
@@ -20,6 +20,30 @@ abstract class DatabaseTest extends TestCase
 
        use TestCaseTrait;
 
+       /**
+        * Creates .htconfig.php for bin/worker.php execution
+        */
+       protected function setUp()
+       {
+               parent::setUp();
+
+               $base_config_file_name = 'htconfig.php';
+               $config_file_name = '.htconfig.php';
+
+               $base_config_file_path = stream_resolve_include_path($base_config_file_name);
+               $config_file_path = dirname($base_config_file_path) . DIRECTORY_SEPARATOR . $config_file_name;
+
+               $config_string = file_get_contents($base_config_file_path);
+
+               $config_string = str_replace('die(', '// die(', $config_string);
+               $config_string = str_replace('your.mysqlhost.com', 'localhost', $config_string);
+               $config_string = str_replace('mysqlusername'     , getenv('USER'), $config_string);
+               $config_string = str_replace('mysqlpassword'     , getenv('PASS'), $config_string);
+               $config_string = str_replace('mysqldatabasename' , getenv('DB'), $config_string);
+
+               file_put_contents($config_file_path, $config_string);
+       }
+
        /**
         * Get database connection.
         *