FOSSology  4.7.1
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  $data = "test for cli log";
33  cli_logger("./cli.log", $data, "w");
34  $file_contents = file_get_contents("./cli.log");
35  $this->assertEquals("$data\n", $file_contents);
36  cli_logger("./cli.log", $data, "a");
37  $file_contents = file_get_contents("./cli.log");
38  $this->assertEquals("$data\n$data\n", $file_contents);
39  cli_logger("./cli.log", $data, "w");
40  $file_contents = file_get_contents("./cli.log");
41  $this->assertEquals("$data\n", $file_contents);
42  }
43 
47  protected function tearDown() : void
48  {
49  if (file_exists("./cli.log")) {
50  unlink("./cli.log");
51  }
52  }
53 }
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