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
|
|||
41 | } |
||
42 | } |
||
43 |
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.