Exemplo n.º 1
0
 public static function tearDownAfterClass()
 {
     // We need to clean up after this test case, since database will not
     // be reset by the suite it initialisation has happened once, see pull req. #234
     // Next: Suite which always prepares the db for you.
     $db = ezpTestDatabaseHelper::create(ezpTestRunner::dsn());
     ezpTestDatabaseHelper::clean($db);
     ezpTestDatabaseHelper::insertDefaultData($db);
 }
    protected function setUp()
    {
        if ( ezpTestRunner::dsn()->dbsyntax !== "postgresql" )
            self::markTestSkipped( "Not running PostgresSQL, skipping" );

        parent::setUp();

        $this->sharedFixture = ezpTestDatabaseHelper::create( ezpTestRunner::dsn() );

        ezpTestDatabaseHelper::clean( $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;
    }
 /**
  * Sets up the database enviroment
  */
 protected function setUp()
 {
     if (ezpTestRunner::dbPerTest()) {
         $dsn = ezpTestRunner::dsn();
         $this->sharedFixture = ezpTestDatabaseHelper::create($dsn);
         if ($this->insertDefaultData === true) {
             ezpTestDatabaseHelper::insertDefaultData($this->sharedFixture);
         }
         if (count($this->sqlFiles > 0)) {
             ezpTestDatabaseHelper::insertSqlData($this->sharedFixture, $this->sqlFiles);
         }
     }
     eZDB::setInstance($this->sharedFixture);
 }