Completed
Push — master ( cbd317...231b94 )
by Henry
09:43
created

tests/phpunit/View/SystemStatusTest.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Tests\View;
3
4
use Redaxscript\Tests\TestCaseAbstract;
5
use Redaxscript\View;
6
7
/**
8
 * SystemStatusTest
9
 *
10
 * @since 3.0.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 *
16
 * @covers Redaxscript\View\SystemStatus
17
 * @covers Redaxscript\View\ViewAbstract
18
 */
19
20
class SystemStatusTest extends TestCaseAbstract
21
{
22
	/**
23
	 * testRender
24
	 *
25
	 * @since 3.0.0
26
	 *
27
	 * @param array $registryArray
28
	 * @param string $expect
29
	 *
30
	 * @dataProvider providerAutoloader
31
	 */
32
33
	public function testRender(array $registryArray = [], string $expect = null)
34
	{
35
		/* setup */
36
37
		$this->_registry->init($registryArray);
38
		$systemStatus = new View\SystemStatus($this->_registry, $this->_language);
39
40
		/* actual */
41
42
		$actual = $systemStatus->render();
43
44
		/* compare */
45
46
		$this->assertEquals($expect, $actual);
47
	}
48
49
	/**
50
	 * testValidateError
51
	 *
52
	 * @since 3.0.0
53
	 *
54
	 * @param array $registryArray
55
	 * @param array $expectArray
56
	 *
57
	 * @dataProvider providerAutoloader
58
	 */
59
60
	public function testValidateError(array $registryArray = [], array $expectArray = [])
61
	{
62
		/* setup */
63
64
		$this->_registry->init($registryArray);
65
		$systemStatus = new View\SystemStatus($this->_registry, $this->_language);
66
67
		/* actual */
68
69
		$actualArray = $this->callMethod($systemStatus, '_validateError');
0 ignored issues
show
$systemStatus is of type object<Redaxscript\View\SystemStatus>, but the function expects a null|object<Redaxscript\Tests\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
70
71
		/* compare */
72
73
		$this->assertEquals($expectArray, $actualArray);
74
	}
75
76
	/**
77
	 * testValidateWarning
78
	 *
79
	 * @since 3.0.0
80
	 *
81
	 * @param array $registryArray
82
	 * @param array $expectArray
83
	 *
84
	 * @dataProvider providerAutoloader
85
	 */
86
87
	public function testValidateWarning(array $registryArray = [], array $expectArray = [])
88
	{
89
		/* setup */
90
91
		$this->_registry->init($registryArray);
92
		$systemStatus = new View\SystemStatus($this->_registry, $this->_language);
93
94
		/* actual */
95
96
		$actualArray = $this->callMethod($systemStatus, '_validateWarning');
0 ignored issues
show
$systemStatus is of type object<Redaxscript\View\SystemStatus>, but the function expects a null|object<Redaxscript\Tests\object>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
97
98
		/* compare */
99
100
		$this->assertEquals($expectArray, $actualArray);
101
	}
102
}
103