Completed
Push — master ( 4e146b...a6625c )
by Henry
08:17
created

tests/unit/AutoloaderTest.php (1 issue)

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;
3
4
use Redaxscript\Autoloader;
5
use function class_exists;
6
7
/**
8
 * AutoloaderTest
9
 *
10
 * @since 2.1.0
11
 *
12
 * @package Redaxscript
13
 * @category Tests
14
 * @author Henry Ruhs
15
 * @author Sven Weingartner
16
 *
17
 * @covers Redaxscript\Autoloader
18
 */
19
20
class AutoloaderTest extends TestCaseAbstract
21
{
22
	/**
23
	 * testInit
24
	 *
25
	 * @since 3.0.0
26
	 */
27
28
	public function testInit() : void
29
	{
30
		/* setup */
31
32
		$autoloader = new Autoloader();
33
		$autoloader->init('test');
34
35
		/* actual */
36
37
		$actualArray = $this->getProperty($autoloader, '_autoloadArray');
0 ignored issues
show
$autoloader is of type object<Redaxscript\Autoloader>, 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...
38
39
		/* compare */
40
41
		$this->assertContains('test', $actualArray);
42
	}
43
44
	/**
45
	 * testFilePath
46
	 *
47
	 * @since 2.2.0
48
	 *
49
	 * @param string $className
50
	 * @param bool $expect
51
	 *
52
	 * @dataProvider providerAutoloader
53
	 */
54
55
	public function testFilePath(string $className = null, bool $expect = null) : void
56
	{
57
		/* actual */
58
59
		$actual = class_exists($className);
60
61
		/* compare */
62
63
		$this->assertEquals($expect, $actual);
64
	}
65
}
66
67