Beispiel #1
0
    /**
     * Test that \flo\Factory::create() handles environments variables correctly.
     */
    public function testcreateFlo()
    {
        $this->writeConfig();
        $this->flo = \flo\Factory::create();
        // Lets
        $this->assertEquals('Publisher7_nbcuflo', $this->flo->getConfig()->get('repository'));
        $override_project_config = <<<EOT
---
organization: Another
repository: Publisher7_nbcuflo
shortname: Publisher7_nbcuflo
github_git_uri: git@github.com:NBCUOTS/Publisher7_nbcuflo.git
pull_request:
  domain: pr.publisher7.com
  prefix: flo-test
scripts:
  pre_deploy_cmd:
  - scripts/pre-deploy.sh
  post_deploy_cmd:
  - scripts/post-deploy.sh
EOT;
        putenv('FLO=' . $override_project_config);
        $this->flo2 = \flo\Factory::create();
        // Now lets assert that the Orgnization is Another and not NBCUOTS.
        $this->assertEquals('Another', $this->flo2->getConfig()->get('organization'));
    }
Beispiel #2
0
 /**
  * Generate Settings PHP for a specific PR.
  *
  * @param int $pr_number
  *   Pull Request Number used to build the settings.php file.
  * @param string $site_dir
  *   Optional site directory to place settings.local.php in.
  * @param string $database
  *   Optional database name.
  *
  * @throws \Exception
  */
 public static function generateSettings($pr_number, $site_dir = 'default', $database = NULL)
 {
     $flo = Factory::create();
     $config = $flo->getConfig()->all();
     $fs = new Filesystem();
     $path = $config['pull_request']['prefix'] . '-' . $pr_number . '.' . $config['pull_request']['domain'];
     $url = "http://{$path}";
     $local_site_path = $config['pr_directories'] . $path;
     $local_settings_php = $local_site_path . "/docroot/sites/{$site_dir}/settings.local.php";
     if (!is_numeric($pr_number)) {
         throw new \Exception("PR must be a number.");
     }
     $database_name = $database ? $database : $config['pull_request']['prefix'] . "_" . $pr_number;
     $output = "<?php\n\n  \$base_url = '{$url}';\n\n  \$databases['default'] = array ('default' =>\n    array (\n      'database' => '{$database_name}',\n      'username' => 'root',\n      'password' => '',\n      'host' => '127.0.0.1',\n      'port' => '',\n      'driver' => 'mysql',\n      'prefix' => '',\n    ),\n  );\n\n  // Set the program name for syslog.module.\n  \$conf['syslog_identity'] = '{$config['pull_request']['prefix']}_{$pr_number}';\n\n  // Set up memcache settings.\n  \$conf['memcache_key_prefix'] = '{$config['pull_request']['prefix']}_{$pr_number}_';\n  \$conf['memcache_servers'] = array(\n    '127.0.0.1:11211' => 'default',\n  );\n\n  // Imagemagick path to convert binary setting.\n  \$conf['imagemagick_convert'] = '/usr/bin/convert';";
     try {
         $fs->dumpFile($local_settings_php, $output);
     } catch (IOExceptionInterface $e) {
         echo "An error occurred while creating settings.inc file at " . $e->getPath();
     }
 }
Beispiel #3
0
 /**
  * Get a configured Flo object.
  *
  * @return Flo
  *   A configured Flo object.
  */
 public function getFlo()
 {
     if (NULL === $this->flo) {
         $this->flo = Factory::create();
     }
     return $this->flo;
 }