FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
test_common_cli.php
Go to the documentation of this file.
1 <?php
2 /*
3  Copyright (C) 2011 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 
24 require_once(dirname(__FILE__) . '/../common-cli.php');
25 
29 class test_common_cli extends \PHPUnit\Framework\TestCase
30 {
34  protected function setUp()
35  {
36  }
37 
41  function testcli_logger()
42  {
43  print "Start unit test for common-cli.php\n";
44  print "test function cli_logger()\n";
45  $data = "test for cli log";
46  cli_logger("./cli.log", $data, "w");
47  $file_contents = file_get_contents("./cli.log");
48  $this->assertEquals("$data\n", $file_contents);
49  cli_logger("./cli.log", $data, "a");
50  $file_contents = file_get_contents("./cli.log");
51  $this->assertEquals("$data\n$data\n", $file_contents);
52  cli_logger("./cli.log", $data, "w");
53  $file_contents = file_get_contents("./cli.log");
54  $this->assertEquals("$data\n", $file_contents);
55  print "unit test for common-cli.php end\n";
56  }
57 
61  protected function tearDown()
62  {
63  if (file_exists("./cli.log")) {
64  unlink("./cli.log");
65  }
66  }
67 }
testcli_logger()
test for cli_logger
cli_logger($handle, $message, $mode='a')
Write/append a message to the log handle passed in.
Definition: common-cli.php:74
tearDown()
clean the env
setUp()
initialization