Issues (52)

tests/Controllers/DevHealthControllerTest.php (1 issue)

Severity
1
<?php
2
3
namespace SilverStripe\EnvironmentCheck\Tests\Controllers;
4
5
use SilverStripe\Control\HTTPRequest;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\EnvironmentCheck\Controllers\DevHealthController;
8
use SilverStripe\EnvironmentCheck\EnvironmentChecker;
9
10
/**
11
 * Class DevHealthControllerTest
12
 *
13
 * @mixin PHPUnit_Framework_TestCase
14
 *
15
 * @package environmentcheck
16
 */
17
class DevHealthControllerTest extends SapphireTest
18
{
19
    /**
20
     * {@inheritDoc}
21
     * @var array
22
     */
23
    protected $usesDatabase = true;
24
25
    public function testIndexCreatesChecker()
26
    {
27
        $controller = new DevHealthController();
28
29
        $request = new HTTPRequest('GET', 'example.com');
30
31
        // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty
32
        // permission type strings, which is what health check uses.
33
34
        putenv('ENVCHECK_BASICAUTH_USERNAME="foo"');
35
        putenv('ENVCHECK_BASICAUTH_PASSWORD="bar"');
36
37
        $_SERVER['PHP_AUTH_USER'] = 'foo';
38
        $_SERVER['PHP_AUTH_PW'] = 'bar';
39
40
        $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request));
0 ignored issues
show
The call to SilverStripe\Environment...althController::index() has too many arguments starting with $request. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        $this->assertInstanceOf(EnvironmentChecker::class, $controller->/** @scrutinizer ignore-call */ index($request));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
41
    }
42
}
43