]> 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 03:10:33 +0000 (23:10 -0400)
tests/DatabaseTest.php

index 12150932c9dba2a6da019514d2284da17f53f010..408e4b0cd3cba2503303c1125f69559d179905b2 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 = str_replace('your.mysqlhost.com', 'localhost');
+               $config_string = str_replace('mysqlusername'     , getenv('USER'));
+               $config_string = str_replace('mysqlpassword'     , getenv('PASS'));
+               $config_string = str_replace('mysqldatabasename' , getenv('DB'));
+
+               file_put_contents($config_file_path, $config_string);
+       }
+
        /**
         * Get database connection.
         *