FOSSology  4.4.0
Open Source License Compliance by Open Source Software
test_common_cli.php
Go to the documentation of this file.
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
13 require_once(dirname(__FILE__) . '/../common-cli.php');
14 
18 class test_common_cli extends \PHPUnit\Framework\TestCase
19 {
23  protected function setUp() : void
24  {
25  }
26 
30  function testcli_logger()
31  {
32  print "Start unit test for common-cli.php\n";
33  print "test function cli_logger()\n";
34  $data = "test for cli log";
35  cli_logger("./cli.log", $data, "w");
36  $file_contents = file_get_contents("./cli.log");
37  $this->assertEquals("$data\n", $file_contents);
38  cli_logger("./cli.log", $data, "a");
39  $file_contents = file_get_contents("./cli.log");
40  $this->assertEquals("$data\n$data\n", $file_contents);
41  cli_logger("./cli.log", $data, "w");
42  $file_contents = file_get_contents("./cli.log");
43  $this->assertEquals("$data\n", $file_contents);
44  print "unit test for common-cli.php end\n";
45  }
46 
50  protected function tearDown() : void
51  {
52  if (file_exists("./cli.log")) {
53  unlink("./cli.log");
54  }
55  }
56 }
setUp()
initialization
tearDown()
clean the env
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:63