public static function tearDownAfterClass()
 {
     $app = new Application('test');
     \phrasea::reset_sbasDatas($app['phraseanet.appbox']);
     \phrasea::reset_baseDatas($app['phraseanet.appbox']);
     parent::tearDownAfterClass();
 }
 public function testInstall()
 {
     $app = new Application(Application::ENV_TEST);
     \phrasea::reset_sbasDatas($app['phraseanet.appbox']);
     \phrasea::reset_baseDatas($app['phraseanet.appbox']);
     $app->bindRoutes();
     $parser = new Parser();
     $config = $parser->parse(file_get_contents(__DIR__ . '/../../../../../config/configuration.yml'));
     $credentials = $config['main']['database'];
     $configFile = __DIR__ . '/configuration.yml';
     $compiledFile = __DIR__ . '/configuration.yml.php';
     @unlink($configFile);
     @unlink($compiledFile);
     $app['configuration.store'] = $app->share(function () use($configFile, $compiledFile) {
         return new Configuration(new Yaml(), new Compiler(), $configFile, $compiledFile, true);
     });
     $app['conf'] = $app->share(function () use($app) {
         return new PropertyAccess($app['configuration.store']);
     });
     $app['phraseanet.appbox'] = $app->share(function () use($app) {
         return new \appbox($app);
     });
     $abInfo = ['host' => $credentials['host'], 'port' => $credentials['port'], 'user' => $credentials['user'], 'password' => $credentials['password'], 'dbname' => 'ab_setup_test'];
     $abConn = $app['dbal.provider']($abInfo);
     $dbConn = $app['dbal.provider'](['host' => $credentials['host'], 'port' => $credentials['port'], 'user' => $credentials['user'], 'password' => $credentials['password'], 'dbname' => 'db_setup_test']);
     $key = $app['orm.add']($abInfo);
     $app['orm.ems.default'] = $key;
     $dataPath = __DIR__ . '/../../../../../datas/';
     $installer = new Installer($app);
     $installer->install(uniqid('admin') . '@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, 'en');
     $this->assertTrue($app['configuration.store']->isSetup());
     $this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
     $databox = current($app->getDataboxes());
     $this->assertContains('<path>' . realpath($dataPath) . '/db_setup_test/subdefs</path>', $databox->get_structure());
     $conf = $app['configuration.store']->getConfig();
     $this->assertArrayHasKey('main', $conf);
     $this->assertArrayHasKey('key', $conf['main']);
     $this->assertGreaterThan(10, strlen($conf['main']['key']));
     @unlink($configFile);
     @unlink($compiledFile);
     $app['connection.pool.manager']->closeAll();
 }
Exemple #3
0
 /**
  *
  * @param  Application $app
  * @param  string      $host
  * @param  int         $port
  * @param  string      $user
  * @param  string      $password
  * @param  string      $dbname
  * @param  registry    $registry
  * @return databox
  */
 public static function mount(Application $app, $host, $port, $user, $password, $dbname)
 {
     $conn = $app['dbal.provider']->get(['host' => $host, 'port' => $port, 'user' => $user, 'password' => $password, 'dbname' => $dbname]);
     $conn->connect();
     $conn = $app['phraseanet.appbox']->get_connection();
     $sql = 'SELECT MAX(ord) as ord FROM sbas';
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if ($row) {
         $ord = $row['ord'] + 1;
     }
     $sql = 'INSERT INTO sbas (sbas_id, ord, host, port, dbname, sqlengine, user, pwd)
           VALUES (null, :ord, :host, :port, :dbname, "MYSQL", :user, :password)';
     $stmt = $conn->prepare($sql);
     $stmt->execute([':ord' => $ord, ':host' => $host, ':port' => $port, ':dbname' => $dbname, ':user' => $user, ':password' => $password]);
     $stmt->closeCursor();
     $sbas_id = (int) $conn->lastInsertId();
     $app['phraseanet.appbox']->delete_data_from_cache(appbox::CACHE_LIST_BASES);
     $databox = $app['phraseanet.appbox']->get_databox($sbas_id);
     $databox->delete_data_from_cache(databox::CACHE_COLLECTIONS);
     $app['phraseanet.appbox']->delete_data_from_cache(appbox::CACHE_SBAS_IDS);
     phrasea::reset_sbasDatas($app['phraseanet.appbox']);
     cache_databox::update($app, $databox->get_sbas_id(), 'structure');
     return $databox;
 }
Exemple #4
0
 public function delete_data_from_cache($option = null)
 {
     $appbox = $this->get_base_type() == self::APPLICATION_BOX ? $this : $this->get_appbox();
     if ($option === appbox::CACHE_LIST_BASES) {
         $keys = [$this->get_cache_key(appbox::CACHE_LIST_BASES)];
         phrasea::reset_sbasDatas($appbox);
         phrasea::reset_baseDatas($appbox);
         phrasea::clear_sbas_params($this->app);
         $keys[] = $this->get_cache_key(appbox::CACHE_SBAS_IDS);
         return $this->get_cache()->deleteMulti($keys);
     }
     if (is_array($option)) {
         foreach ($option as $key => $value) {
             $option[$key] = $this->get_cache_key($value);
         }
         return $this->get_cache()->deleteMulti($option);
     } else {
         return $this->get_cache()->delete($this->get_cache_key($option));
     }
 }