Skip to content

Commit dbaaea7

Browse files
committed
Let's test all permutations
1 parent 0ea3e9e commit dbaaea7

File tree

2 files changed

+90
-2
lines changed

2 files changed

+90
-2
lines changed

tests/src/Rules/EntityQueryHasAccessCheckRuleTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,23 @@ public function cases(): \Generator
9999

100100
yield 'bug-494.php' => [
101101
[__DIR__.'/data/bug-494.php'],
102-
[]
102+
[
103+
[
104+
'Relying on entity queries to check access by default is deprecated in drupal:9.2.0 and an error will be thrown from drupal:10.0.0. Call \Drupal\Core\Entity\Query\QueryInterface::accessCheck() with TRUE or FALSE to specify whether access should be checked.',
105+
43,
106+
'See https://www.drupal.org/node/3201242',
107+
],
108+
[
109+
'Relying on entity queries to check access by default is deprecated in drupal:9.2.0 and an error will be thrown from drupal:10.0.0. Call \Drupal\Core\Entity\Query\QueryInterface::accessCheck() with TRUE or FALSE to specify whether access should be checked.',
110+
103,
111+
'See https://www.drupal.org/node/3201242',
112+
],
113+
[
114+
'Relying on entity queries to check access by default is deprecated in drupal:9.2.0 and an error will be thrown from drupal:10.0.0. Call \Drupal\Core\Entity\Query\QueryInterface::accessCheck() with TRUE or FALSE to specify whether access should be checked.',
115+
108,
116+
'See https://www.drupal.org/node/3201242',
117+
],
118+
]
103119
];
104-
105120
}
106121
}

tests/src/Rules/data/bug-494.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@ public function bug494(string $entity_type): void
1919
->accessCheck(FALSE)
2020
->execute();
2121

22+
\Drupal::entityQuery($entity_type)
23+
->accessCheck(TRUE)
24+
->condition('field_test', 'foo', '=')
25+
->execute();
26+
27+
\Drupal::entityQuery($entity_type)
28+
->condition('field_test', 'foo', '=')
29+
->accessCheck(TRUE)
30+
->execute();
31+
32+
\Drupal::entityQuery($entity_type)
33+
->accessCheck()
34+
->condition('field_test', 'foo', '=')
35+
->execute();
36+
37+
\Drupal::entityQuery($entity_type)
38+
->condition('field_test', 'foo', '=')
39+
->accessCheck()
40+
->execute();
41+
42+
// Failing test due to missing accessCheck.
43+
\Drupal::entityQuery($entity_type)
44+
->condition('field_test', 'foo', '=')
45+
->execute();
46+
47+
// Same tests but now with count() chained as well.
2248
\Drupal::entityQuery($entity_type)
2349
->accessCheck(FALSE)
2450
->condition('field_test', 'foo', '=')
@@ -36,5 +62,52 @@ public function bug494(string $entity_type): void
3662
->count()
3763
->accessCheck(FALSE)
3864
->execute();
65+
66+
\Drupal::entityQuery($entity_type)
67+
->accessCheck(TRUE)
68+
->condition('field_test', 'foo', '=')
69+
->count()
70+
->execute();
71+
72+
\Drupal::entityQuery($entity_type)
73+
->condition('field_test', 'foo', '=')
74+
->accessCheck(TRUE)
75+
->count()
76+
->execute();
77+
78+
\Drupal::entityQuery($entity_type)
79+
->condition('field_test', 'foo', '=')
80+
->count()
81+
->accessCheck(TRUE)
82+
->execute();
83+
84+
\Drupal::entityQuery($entity_type)
85+
->accessCheck()
86+
->condition('field_test', 'foo', '=')
87+
->count()
88+
->execute();
89+
90+
\Drupal::entityQuery($entity_type)
91+
->condition('field_test', 'foo', '=')
92+
->accessCheck()
93+
->count()
94+
->execute();
95+
96+
\Drupal::entityQuery($entity_type)
97+
->condition('field_test', 'foo', '=')
98+
->count()
99+
->accessCheck()
100+
->execute();
101+
102+
// Failing tests due to missing accessCheck.
103+
\Drupal::entityQuery($entity_type)
104+
->condition('field_test', 'foo', '=')
105+
->count()
106+
->execute();
107+
108+
\Drupal::entityQuery($entity_type)
109+
->count()
110+
->condition('field_test', 'foo', '=')
111+
->execute();
39112
}
40113
}

0 commit comments

Comments
 (0)