FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
purgeTestEnvironment.php
1 #!/usr/bin/php
2 <?php
3 /*
4  Copyright (C) 2014 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 require_once(__DIR__ . "/TestDbFactory.php");
21 require_once(dirname(dirname(__DIR__)) . "/lib/php/Test/TestInstaller.php");
22 
23 $testDbFactory = new TestDbFactory();
24 
25 $opts = getopt("c:d:", array());
26 
27 if (array_key_exists("c", $opts)) {
28  $sysConfDir = $opts['c'];
29 } else {
30  $sysConfDir = null;
31 }
32 
33 $testInstaller = new Fossology\Lib\Test\TestInstaller($sysConfDir);
34 $testInstaller->clear();
35 
36 if (array_key_exists("d", $opts)) {
37  $srcDir = $opts["d"];
38  foreach (explode(",", $srcDir) as $dir) {
39  if (!empty($dir)) {
40  $testInstaller->uninstall($dir);
41  }
42  }
43 }
44 
45 $testDbFactory->purgeTestDb($sysConfDir);
46