コード例 #1
0
ファイル: TestPgDb.php プロジェクト: rlintu/fossology
 function __construct($dbName = null, $sysConf = null)
 {
     $dbName = strtolower($dbName);
     $testDbFactory = new \TestDbFactory();
     $this->sys_conf = $sysConf;
     if (empty($this->sys_conf)) {
         $this->sys_conf = $testDbFactory->setupTestDb($dbName);
         $dbName = $testDbFactory->getDbName($this->sys_conf);
     }
     $this->dbName = $dbName;
     require_once dirname(dirname(__FILE__)) . '/common-db.php';
     $this->connection = DBconnect($this->sys_conf);
     require dirname(dirname(__FILE__)) . '/common-container.php';
     global $container;
     $logger = new Logger('default');
     // $container->get('logger');
     $this->logFileName = dirname(dirname(dirname(dirname(dirname(__FILE__))))) . 'db.pg.log';
     $logger->pushHandler(new StreamHandler($this->logFileName, Logger::DEBUG));
     $container->get('db.manager')->setDriver(new Postgres($this->connection));
     $this->dbManager = $container->get('db.manager');
     $this->dbManager->queryOnce("DEALLOCATE ALL");
     $this->dropAllTables();
     $this->dropAllSequences();
 }
コード例 #2
0
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
$libPhpDir = dirname(dirname(__DIR__)) . "/lib/php/Test";
require_once __DIR__ . "/TestDbFactory.php";
require_once $libPhpDir . "/TestInstaller.php";
$testDbFactory = new TestDbFactory();
$sysConfDir = $testDbFactory->setupTestDb("fosstest" . time());
$testInstaller = new Fossology\Lib\Test\TestInstaller($sysConfDir);
$testInstaller->init();
$opts = getopt("d:f", array());
if (array_key_exists("d", $opts)) {
    $srcDir = $opts["d"];
    foreach (explode(",", $srcDir) as $dir) {
        if (!empty($dir)) {
            $testInstaller->install($dir);
        }
    }
}
if (array_key_exists("f", $opts)) {
    require_once $libPhpDir . "/TestPgDb.php";
    $testPgDb = new Fossology\Lib\Test\TestPgDb($testDbFactory->getDbName($sysConfDir), $sysConfDir);
    $testPgDb->createSequences(array(), true);
    $testPgDb->createPlainTables(array(), true);
    $testPgDb->alterTables(array(), true);
    $testPgDb->createInheritedTables(array('uploadtree_a'));
}
print $sysConfDir;