Base::onNotSuccessfulTest()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
/**
3
 * Base test class.
4
 *
5
 * @package   Tests
6
 *
7
 * @copyright YetiForce S.A.
8
 * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
9
 * @author    Mariusz Krzaczkowski <[email protected]>
10
 */
11
12
namespace Tests;
13
14
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
abstract class Base extends TestCase
17
{
18
	/** @var mixed Last logs. */
19
	public $logs;
20
21
	/** @var bool Last logs. */
22
	private $logToFile;
23
24
	/**
25
	 * This method is called when a test method did not execute successfully.
26
	 *
27
	 * @codeCoverageIgnore
28
	 *
29
	 * @param \Throwable $t
30
	 */
31
	protected function onNotSuccessfulTest(\Throwable $t): void
32
	{
33
		if (isset($this->logs)) {
34
			echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  LOGS:\n";
35
			//var_export(array_shift($t->getTrace()));
36
			\print_r($this->logs);
37
			echo "\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
38
		}
39
		throw $t;
40
	}
41
42
	/**
43
	 * Disable system logs.
44
	 *
45
	 * @return void
46
	 */
47
	protected function disableLogs(): void
48
	{
49
		$this->logToFile = \App\Log::$logToFile;
50
		\App\Log::$logToFile = false;
51
	}
52
53
	/**
54
	 * Enable system logs.
55
	 *
56
	 * @return void
57
	 */
58
	protected function enableLogs(): void
59
	{
60
		\App\Log::$logToFile = $this->logToFile;
61
	}
62
}
63