-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDisallowEntityArrayAccessRuleTest.php
More file actions
74 lines (68 loc) · 2.44 KB
/
DisallowEntityArrayAccessRuleTest.php
File metadata and controls
74 lines (68 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
declare(strict_types=1);
/**
* Copyright 2024, Cake Development Corporation (https://www.cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2024, Cake Development Corporation (https://www.cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace CakeDC\PHPStan\Test\TestCase\Rule\Model;
use CakeDC\PHPStan\Rule\Model\DisallowEntityArrayAccessRule;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
class DisallowEntityArrayAccessRuleTest extends RuleTestCase
{
/**
* @return \PHPStan\Rules\Rule
*/
protected function getRule(): Rule
{
// getRule() method needs to return an instance of the tested rule
return new DisallowEntityArrayAccessRule();
}
/**
* @return void
*/
public function testRule(): void
{
// first argument: path to the example file that contains some errors that should be reported by MyRule
// second argument: an array of expected errors,
// each error consists of the asserted error message, and the asserted error file line
$this->analyse([__DIR__ . '/Fake/FailingEntityUseLogic.php'], [
[
'Array access to entity App\Model\Entity\Note is not allowed, access as object instead',
24, // asserted error line
],
[
'Array access to entity App\Model\Entity\Note is not allowed, access as object instead',
25, // asserted error line
],
[
'Array access to entity App\Model\Entity\Note is not allowed, access as object instead',
27, // asserted error line
],
[
'Array access to entity Cake\Datasource\EntityInterface is not allowed, access as object instead',
36,
],
[
'Array access to entity App\Model\Entity\User is not allowed, access as object instead',
38, // asserted error line
],
[
'Array access to entity App\Model\Entity\Note is not allowed, access as object instead',
44, // asserted error line
],
]);
}
/**
* @inheritDoc
*/
public static function getAdditionalConfigFiles(): array
{
return [__DIR__ . '/../../../../extension.neon'];
}
}