FOSSology  4.4.0
Open Source License Compliance by Open Source Software
cliParamsTest4UnunpackException.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010-2012 Hewlett-Packard Development Company, L.P.
4  SPDX-FileCopyrightText: © 2015 Siemens AG
5 
6  SPDX-License-Identifier: GPL-2.0-only
7 */
8 
16 require_once __DIR__.'/utility.php';
17 
20 
25 class cliParamsTest4UnunpackExcption extends \PHPUnit\Framework\TestCase
26 {
30  private $agentDir;
31 
35  private $testDb;
39  private $testInstaller;
40 
45  function setUp() : void
46  {
47  $this->testDb = new TestPgDb('ununpackExceptional');
48  $this->agentDir = dirname(__DIR__, 4)."/build/src/ununpack";
49 
50  $sysConf = $this->testDb->getFossSysConf();
51  $this->testInstaller = new TestInstaller($sysConf);
52  $this->testInstaller->init();
53  $this->testInstaller->install($this->agentDir);
54 
55  $this->testDb->createSequences(array(), true);
56  $this->testDb->createPlainTables(array(), true);
57  $this->testDb->createInheritedTables(array());
58  $this->testDb->alterTables(array(), true);
59  }
60 
65  public function tearDown() : void
66  {
67  $this->testInstaller->uninstall($this->agentDir);
68  $this->testInstaller->clear();
69  $this->testInstaller->rmRepo();
70  $this->testDb = null;
71  }
72 
80  public function testValidParam(){
81  global $UNUNPACK_CMD;
82  global $TEST_DATA_PATH;
83  global $TEST_RESULT_PATH;
84  $fossology_testconfig = $this->testDb->getFossSysConf();
85 
86  $UNUNPACK_CMD = $this->agentDir . "/agent/ununpack";
87  if (!empty($TEST_RESULT_PATH))
88  exec("/bin/rm -rf $TEST_RESULT_PATH");
89  $command = "$UNUNPACK_CMD -qCRs $TEST_DATA_PATH/test.iso -d $TEST_RESULT_PATH -c $fossology_testconfig > /dev/null 2>&1";
90  $last = exec($command, $usageOut, $rtn);
91  $this->assertNotEquals($rtn, 0);
92  $this->assertFileNotExists("$TEST_RESULT_PATH/test.iso.dir/test1.zip.tar.dir/test1.zip");
93  }
94 
101  public function testNullFile(){
102  global $TEST_DATA_PATH;
103  global $TEST_RESULT_PATH;
104  $fossology_testconfig = $this->testDb->getFossSysConf();
105 
106  $UNUNPACK_CMD = $this->agentDir . "/agent/ununpack";
107  if (!empty($TEST_RESULT_PATH))
108  exec("/bin/rm -rf $TEST_RESULT_PATH");
109  $command = "$UNUNPACK_CMD -qCR $TEST_DATA_PATH/null_file -d $TEST_RESULT_PATH -c $fossology_testconfig > /dev/null 2>&1";
110  $last = exec($command, $usageOut, $rtn);
111  $this->assertNotEquals($rtn, 0);
112  $this->assertFileNotExists("$TEST_RESULT_PATH/null_file.dir/");
113  }
114 }
Test the ununpack agent cli parameters. (Exceptions)
testValidParam()
Pass an invalid flag to agent which should not run.