FOSSology  4.4.0
Open Source License Compliance by Open Source Software
templatePHPUnit.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
22 // The standard Pear install puts PHPUnit in /usr/share/php/PHPUnit.
23 require_once '/usr/share/php/PHPUnit/Framework.php';
24 
25 // Must have if pathinclude.php is used.
26 global $GlobalReady;
27 $GlobalReady=TRUE;
28 
29 class cli1Test extends \PHPUnit\Framework\TestCase
30 {
31  public function testHelp()
32  {
33  print "Starting testHelp\n";
34 
35  // determine if the system is installed via Upstream or packages
36  $upStream = '/usr/local/share/fossology/php/pathinclude.php';
37  $pkg = '/usr/share/fossology/php/pathinclude.php';
38  if(file_exists($upStream))
39  {
40  require_once($upStream);
41  }
42  else if(file_exists($pkg))
43  {
44  require_once($pkg);
45  }
46  else
47  {
48  $this->assertFileExists($upStream,
49  $message = 'FATAL: cannot find pathinclude.php file, stopping test\n');
50  $this->assertFileExists($pkg,
51  $message = 'FATAL: cannot find pathinclude.php file, stopping test\n');
52  }
53  /*
54  * For this example/template, the nomos agent will be run to get the
55  * usage statement on the command line. Replace the code below with
56  * your test.
57  */
58  $nomos = $AGENTDIR . '/nomos';
59  // run it
60  $last = exec("$nomos -h 2>&1", $out, $rtn);
61  $error = '/usr/local/lib/fossology/agents/nomos: invalid option -- h';
62  $usage = 'Usage: /usr/local/lib/fossology/agents/nomos [options] [file [file [...]]';
63  // Use an assertion to check that the output is what was expected.
64  $this->assertEquals($error, $out[0]);
65  $this->assertEquals($usage, $out[1]);
66  }
67 }