浏览代码

Add tests/TestCase/Utility/LogTest.php

Ishan Vyas 5 年之前
父节点
当前提交
6d11b17b91
共有 1 个文件被更改,包括 45 次插入0 次删除
  1. 45 0
      tests/TestCase/Utility/LogTest.php

+ 45 - 0
tests/TestCase/Utility/LogTest.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace Tools\Test\Utility;
+
+use Tools\TestSuite\TestCase;
+use Tools\Utility\Log;
+
+/**
+ * LogTest class
+ */
+class LogTest extends TestCase {
+	/**
+	 * File path to store log file.
+	 *
+	 * @var string
+	 */
+	private const CUSTOM_FILE_PATH = LOGS . 'my_file.log';
+
+	/**
+	 * setUp method
+	 *
+	 * @return void
+	 */
+	public function setUp() {
+		parent::setUp();
+	}
+
+	/**
+	 * testLogsStringData method
+	 *
+	 * @return void
+	 */
+	public function testLogsStringData() {
+		if (file_exists(self::CUSTOM_FILE_PATH)) {
+            unlink(self::CUSTOM_FILE_PATH);
+        }
+
+		$result = Log::write('It works!', 'my_file');
+
+		$this->assertTrue($result);
+		$this->assertFileExists(self::CUSTOM_FILE_PATH);
+
+		unlink(self::CUSTOM_FILE_PATH);
+	}
+}