/**
  * Test setup
  *
  * Load an instance of file.ini
  * Assigns DB parameters for cluster
  **/
 public function setUp()
 {
     if (!$this->sharedFixture instanceof eZMySQLDB) {
         self::markTestSkipped("Not using mysql interface, skipping");
     }
     parent::setUp();
     // We need to clear the existing handler if it was loaded before the INI
     // settings changes
     if (isset($GLOBALS['eZClusterFileHandler_chosen_handler']) and !$GLOBALS['eZClusterFileHandler_chosen_handler'] instanceof eZDFSFileHandler) {
         unset($GLOBALS['eZClusterFileHandler_chosen_handler']);
     }
     // Load database parameters for cluster
     // The same DSN than the relational database is used
     $fileINI = eZINI::instance('file.ini');
     $this->previousFileHandler = $fileINI->variable('ClusteringSettings', 'FileHandler');
     $fileINI->setVariable('ClusteringSettings', 'FileHandler', 'eZDFSFileHandler');
     $dsn = ezpTestRunner::dsn()->parts;
     $fileINI->setVariable('eZDFSClusteringSettings', 'DBHost', $dsn['host']);
     $fileINI->setVariable('eZDFSClusteringSettings', 'DBPort', $dsn['port']);
     $fileINI->setVariable('eZDFSClusteringSettings', 'DBSocket', $dsn['socket']);
     $fileINI->setVariable('eZDFSClusteringSettings', 'DBName', $dsn['database']);
     $fileINI->setVariable('eZDFSClusteringSettings', 'DBUser', $dsn['user']);
     $fileINI->setVariable('eZDFSClusteringSettings', 'DBPassword', $dsn['password']);
     $fileINI->setVariable('eZDFSClusteringSettings', 'MountPointPath', $this->DFSPath);
     if (!file_exists($this->DFSPath)) {
         eZDir::doMkdir($this->DFSPath, 0755);
         $this->haveToRemoveDFSPath = true;
     }
     ezpTestDatabaseHelper::insertSqlData($this->sharedFixture, $this->sqlFiles);
     $this->db = $this->sharedFixture;
 }
 /**
  * Test setup
  *
  * Load an instance of file.ini
  * Assigns DB parameters for cluster
  **/
 public function setUp()
 {
     parent::setUp();
     self::setUpDatabase($this->clusterClass);
     if (!file_exists(self::$DFSPath)) {
         eZDir::doMkdir(self::$DFSPath, 0755);
         $this->haveToRemoveDFSPath = true;
     }
     $this->db = eZDB::instance();
 }
 public function setUp()
 {
     parent::setUp();
     $this->previousFileHandler = eZINI::instance('file.ini')->variable('ClusteringSettings', 'FileHandler');
     $this->DFSPath = eZDFSFileHandlerTest::getDfsPath();
     eZDFSFileHandlerTest::setUpDatabase();
     if (!file_exists($this->DFSPath)) {
         eZDir::doMkdir($this->DFSPath, 0755);
         $this->haveToRemoveDFSPath = true;
     }
     $this->db = $this->sharedFixture;
 }
    /**
     * Test setup
     *
     * Load an instance of file.ini
     * Assigns DB parameters for cluster
     */
    public function setUp()
    {
        if ( ezpTestRunner::dsn()->dbsyntax !== 'mysql' && ezpTestRunner::dsn()->dbsyntax !== 'mysqli' )
            self::markTestSkipped( "Not running MySQL, skipping" );

        parent::setUp();
        $this->sharedFixture = ezpTestDatabaseHelper::create( ezpTestRunner::dsn() );
        ezpTestDatabaseHelper::insertSqlData( $this->sharedFixture,  array( 'tests/tests/kernel/classes/clusterfilehandlers/sql/cluster_dfs_schema.sql' ) );

        // We need to clear the existing handler if it was loaded before the INI
        // settings changes
        if ( !eZClusterFileHandler::$globalHandler instanceof eZDFSFileHandler )
            eZClusterFileHandler::$globalHandler = null;

        unset( $GLOBALS['eZClusterInfo'] );

        // Load database parameters for cluster
        // The same DSN than the relational database is used
        $fileINI = eZINI::instance( 'file.ini' );
        $this->previousFileHandler = $fileINI->variable( 'ClusteringSettings', 'FileHandler' );
        $fileINI->setVariable( 'ClusteringSettings', 'FileHandler', 'eZDFSFileHandler' );

        $dsn = ezpTestRunner::dsn()->parts;
        switch ( $dsn['phptype'] )
        {
            case 'mysql':
                $backend = 'eZDFSFileHandlerMySQLBackend';
                break;

            case 'mysqli':
                $backend = 'eZDFSFileHandlerMySQLiBackend';
                break;

            default:
                $this->markTestSkipped( "Unsupported database type '{$dsn['phptype']}'" );
        }
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'DBBackend', $backend );
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'DBHost',    $dsn['host'] );
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'DBPort',    $dsn['port'] );
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'DBSocket',  $dsn['socket'] );
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'DBName',    $dsn['database'] );
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'DBUser',    $dsn['user'] );
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'DBPassword', $dsn['password'] );
        $fileINI->setVariable( 'eZDFSClusteringSettings', 'MountPointPath', $this->DFSPath );

        if ( !file_exists( $this->DFSPath ) )
        {
            eZDir::doMkdir( $this->DFSPath, 0755 );
            $this->haveToRemoveDFSPath = true;
        }

        $this->db = $this->sharedFixture;
    }
Beispiel #5
0
 static function cleanupEmptyDirectories($dir)
 {
     $dir = eZDir::cleanPath($dir, self::SEPARATOR_UNIX);
     $dirElements = explode('/', $dir);
     if (count($dirElements) == 0) {
         return true;
     }
     $currentDir = $dirElements[0];
     $result = true;
     if (!file_exists($currentDir) and $currentDir != "") {
         $result = eZDir::doMkdir($currentDir, $perm);
     }
     if (!$result) {
         return false;
     }
     for ($i = count($dirElements); $i > 0; --$i) {
         $dirpath = implode('/', array_slice($dirElements, 0, $i));
         if (file_exists($dirpath) and is_dir($dirpath)) {
             $rmdirStatus = @rmdir($dirpath);
             if (!$rmdirStatus) {
                 return true;
             }
         }
     }
     return true;
 }