FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
cliParamsTest4UnunpackException.php
Go to the documentation of this file.
1 <?php
2 /*
3  Copyright (C) 2010-2012 Hewlett-Packard Development Company, L.P.
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 
27 require_once './utility.php';
28 
31 
36 class cliParamsTest4UnunpackExcption extends \PHPUnit\Framework\TestCase
37 {
41  private $agentDir;
42 
46  private $testDb;
50  private $testInstaller;
51 
56  function setUp()
57  {
58  $this->testDb = new TestPgDb('ununpackExceptional');
59  $this->agentDir = dirname(dirname(__DIR__))."/";
60 
61  $sysConf = $this->testDb->getFossSysConf();
62  $this->testInstaller = new TestInstaller($sysConf);
63  $this->testInstaller->init();
64  $this->testInstaller->install($this->agentDir);
65 
66  $this->testDb->createSequences(array(), true);
67  $this->testDb->createPlainTables(array(), true);
68  $this->testDb->createInheritedTables(array());
69  $this->testDb->alterTables(array(), true);
70  }
71 
76  public function tearDown()
77  {
78  $this->testInstaller->uninstall($this->agentDir);
79  $this->testInstaller->clear();
80  $this->testInstaller->rmRepo();
81  $this->testDb = null;
82  }
83 
91  public function testValidParam(){
92  global $UNUNPACK_CMD;
93  global $TEST_DATA_PATH;
94  global $TEST_RESULT_PATH;
95  $fossology_testconfig = $this->testDb->getFossSysConf();
96 
97  $UNUNPACK_CMD = $this->agentDir . "/agent/ununpack";
98  if (!empty($TEST_RESULT_PATH))
99  exec("/bin/rm -rf $TEST_RESULT_PATH");
100  $command = "$UNUNPACK_CMD -qCRs $TEST_DATA_PATH/test.iso -d $TEST_RESULT_PATH -c $fossology_testconfig > /dev/null 2>&1";
101  $last = exec($command, $usageOut, $rtn);
102  $this->assertNotEquals($rtn, 0);
103  $this->assertFileNotExists("$TEST_RESULT_PATH/test.iso.dir/test1.zip.tar.dir/test1.zip");
104  }
105 
112  public function testNullFile(){
113  global $TEST_DATA_PATH;
114  global $TEST_RESULT_PATH;
115  $fossology_testconfig = $this->testDb->getFossSysConf();
116 
117  $UNUNPACK_CMD = $this->agentDir . "/agent/ununpack";
118  if (!empty($TEST_RESULT_PATH))
119  exec("/bin/rm -rf $TEST_RESULT_PATH");
120  $command = "$UNUNPACK_CMD -qCR $TEST_DATA_PATH/null_file -d $TEST_RESULT_PATH -c $fossology_testconfig > /dev/null 2>&1";
121  $last = exec($command, $usageOut, $rtn);
122  $this->assertNotEquals($rtn, 0);
123  $this->assertFileNotExists("$TEST_RESULT_PATH/null_file.dir/");
124  }
125 }
Test the ununpack agent cli parameters. (Exceptions)
testValidParam()
Pass an invalid flag to agent which should not run.