FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
createTestEnvironment.php
1 #!/usr/bin/php
2 <?php
3 /*
4  Copyright (C) 2015 Siemens AG
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 $libPhpDir = dirname(dirname(__DIR__)) . "/lib/php/Test";
21 
22 require_once(__DIR__ . "/TestDbFactory.php");
23 require_once($libPhpDir."/TestInstaller.php");
24 
25 $testDbFactory = new TestDbFactory();
26 
27 $sysConfDir = $testDbFactory->setupTestDb("fosstest" . time());
28 
29 $testInstaller = new Fossology\Lib\Test\TestInstaller($sysConfDir);
30 $testInstaller->init();
31 
32 $opts = getopt("d:f", array());
33 if (array_key_exists("d", $opts)) {
34  $srcDir = $opts["d"];
35  foreach (explode(",", $srcDir) as $dir) {
36  if (!empty($dir)) {
37  $testInstaller->install($dir);
38  }
39  }
40 }
41 if (array_key_exists("f", $opts)) {
42  require_once($libPhpDir."/TestPgDb.php");
43  $testPgDb = new Fossology\Lib\Test\TestPgDb($testDbFactory->getDbName($sysConfDir), $sysConfDir);
44  $testPgDb->createSequences(array(), true);
45  $testPgDb->createPlainTables(array(), true);
46  $testPgDb->createInheritedTables(array());
47  $testPgDb->alterTables(array(), true);
48  $testPgDb->createInheritedTables(array('uploadtree_a'));
49 }
50 
51 print $sysConfDir;
52