FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
templatePHPUnit.php
1 <?php
2 /*
3  Copyright (C) 2010 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
33 // The standard Pear install puts PHPUnit in /usr/share/php/PHPUnit.
34 require_once '/usr/share/php/PHPUnit/Framework.php';
35 
36 // Must have if pathinclude.php is used.
37 global $GlobalReady;
38 $GlobalReady=TRUE;
39 
40 class cli1Test extends \PHPUnit\Framework\TestCase
41 {
42  public function testHelp()
43  {
44  print "Starting testHelp\n";
45 
46  // determine if the system is installed via Upstream or packages
47  $upStream = '/usr/local/share/fossology/php/pathinclude.php';
48  $pkg = '/usr/share/fossology/php/pathinclude.php';
49  if(file_exists($upStream))
50  {
51  require_once($upStream);
52  }
53  else if(file_exists($pkg))
54  {
55  require_once($pkg);
56  }
57  else
58  {
59  $this->assertFileExists($upStream,
60  $message = 'FATAL: cannot find pathinclude.php file, stopping test\n');
61  $this->assertFileExists($pkg,
62  $message = 'FATAL: cannot find pathinclude.php file, stopping test\n');
63  }
64  /*
65  * For this example/template, the nomos agent will be run to get the
66  * usage statement on the command line. Replace the code below with
67  * your test.
68  */
69  $nomos = $AGENTDIR . '/nomos';
70  // run it
71  $last = exec("$nomos -h 2>&1", $out, $rtn);
72  $error = '/usr/local/lib/fossology/agents/nomos: invalid option -- h';
73  $usage = 'Usage: /usr/local/lib/fossology/agents/nomos [options] [file [file [...]]';
74  // Use an assertion to check that the output is what was expected.
75  $this->assertEquals($error, $out[0]);
76  $this->assertEquals($usage, $out[1]);
77  }
78 }
79 ?>