public function duplicateDatabaseTo($new_database_name)
 {
     $old_database_name = $this->getShop()->getMysqlDatabase();
     $this->buildMysqlCommand('mysqladmin', ['create', $new_database_name])->run();
     Process::pipe($this->buildMysqlCommand('mysqldump', [$old_database_name]), $this->buildMysqlCommand('mysql', [$new_database_name]));
 }
 public static function spawnSelenium($headless = false)
 {
     $display = null;
     if ($headless) {
         for ($displayNumber = 10; $displayNumber < 50; ++$displayNumber) {
             try {
                 $xprocess = new Process('Xvfb', [':' . $displayNumber], ['-ac' => ''], ['upid' => true]);
                 $xprocess->run();
                 sleep(1);
             } catch (Exception $e) {
                 // never mind, try next display...
             }
             if ($xprocess->running()) {
                 self::$processesToKill[] = $xprocess;
                 $display = ':' . $displayNumber;
                 break;
             }
         }
     }
     list($process, $port) = self::buildStartProcess();
     self::$processesToKill[] = $process;
     if ($display) {
         $process->setEnv('DISPLAY', $display);
     }
     $process->run(null, 'selenium.log', 'selenium.log');
     if ($process->running()) {
         self::$host = 'http://127.0.0.1:' . $port . '/wd/hub';
         $spinner = new Spinner('Could not automatically start selenium.', 20, 1000);
         $spinner->assertBecomesTrue(function () {
             $ch = curl_init(self::$host . '/status');
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $status = json_decode(curl_exec($ch), true);
             curl_close($ch);
             return isset($status['status']) && $status['status'] === 0;
         });
     }
     register_shutdown_function(function () {
         self::unSpawnSelenium();
     });
 }