11
11
12
12
namespace Symfony \Component \Security \Acl \Tests \Dbal ;
13
13
14
+ use Doctrine \DBAL \Configuration ;
14
15
use Doctrine \DBAL \DriverManager ;
16
+ use Doctrine \DBAL \Schema \DefaultSchemaManagerFactory ;
15
17
use PHPUnit \Framework \TestCase ;
16
18
use Symfony \Component \Security \Acl \Dbal \AclProvider ;
17
19
use Symfony \Component \Security \Acl \Dbal \Schema ;
@@ -146,10 +148,22 @@ public function testFindAcl()
146
148
147
149
protected function setUp (): void
148
150
{
149
- $ this ->connection = DriverManager::getConnection ([
150
- 'driver ' => 'pdo_sqlite ' ,
151
- 'memory ' => true ,
152
- ]);
151
+ $ configuration = new Configuration ();
152
+
153
+ /**
154
+ * @psalm-suppress RedundantCondition Since we are compatibles with DBAL 2 and 3, we need to check if the method exists
155
+ */
156
+ if (method_exists ($ configuration , 'setSchemaManagerFactory ' )) {
157
+ $ configuration ->setSchemaManagerFactory (new DefaultSchemaManagerFactory ());
158
+ }
159
+
160
+ $ this ->connection = DriverManager::getConnection (
161
+ [
162
+ 'driver ' => 'pdo_sqlite ' ,
163
+ 'memory ' => true ,
164
+ ],
165
+ $ configuration
166
+ );
153
167
154
168
// import the schema
155
169
$ schema = new Schema ($ this ->getOptions ());
@@ -160,27 +174,50 @@ protected function setUp(): void
160
174
// populate the schema with some test data
161
175
$ insertClassStmt = $ this ->connection ->prepare ('INSERT INTO acl_classes (id, class_type) VALUES (?, ?) ' );
162
176
foreach ($ this ->getClassData () as $ data ) {
163
- $ insertClassStmt ->executeStatement ($ data );
177
+ $ insertClassStmt ->bindValue (1 , $ data [0 ]);
178
+ $ insertClassStmt ->bindValue (2 , $ data [1 ]);
179
+ $ insertClassStmt ->executeStatement ();
164
180
}
165
181
166
182
$ insertSidStmt = $ this ->connection ->prepare ('INSERT INTO acl_security_identities (id, identifier, username) VALUES (?, ?, ?) ' );
167
183
foreach ($ this ->getSidData () as $ data ) {
168
- $ insertSidStmt ->executeStatement ($ data );
184
+ $ insertSidStmt ->bindValue (1 , $ data [0 ]);
185
+ $ insertSidStmt ->bindValue (2 , $ data [1 ]);
186
+ $ insertSidStmt ->bindValue (3 , $ data [2 ]);
187
+ $ insertSidStmt ->executeStatement ();
169
188
}
170
189
171
190
$ insertOidStmt = $ this ->connection ->prepare ('INSERT INTO acl_object_identities (id, class_id, object_identifier, parent_object_identity_id, entries_inheriting) VALUES (?, ?, ?, ?, ?) ' );
172
191
foreach ($ this ->getOidData () as $ data ) {
173
- $ insertOidStmt ->executeStatement ($ data );
192
+ $ insertOidStmt ->bindValue (1 , $ data [0 ]);
193
+ $ insertOidStmt ->bindValue (2 , $ data [1 ]);
194
+ $ insertOidStmt ->bindValue (3 , $ data [2 ]);
195
+ $ insertOidStmt ->bindValue (4 , $ data [3 ]);
196
+ $ insertOidStmt ->bindValue (5 , $ data [4 ]);
197
+ $ insertOidStmt ->executeStatement ();
174
198
}
175
199
176
200
$ insertEntryStmt = $ this ->connection ->prepare ('INSERT INTO acl_entries (id, class_id, object_identity_id, field_name, ace_order, security_identity_id, mask, granting, granting_strategy, audit_success, audit_failure) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ' );
177
201
foreach ($ this ->getEntryData () as $ data ) {
178
- $ insertEntryStmt ->executeStatement ($ data );
202
+ $ insertEntryStmt ->bindValue (1 , $ data [0 ]);
203
+ $ insertEntryStmt ->bindValue (2 , $ data [1 ]);
204
+ $ insertEntryStmt ->bindValue (3 , $ data [2 ]);
205
+ $ insertEntryStmt ->bindValue (4 , $ data [3 ]);
206
+ $ insertEntryStmt ->bindValue (5 , $ data [4 ]);
207
+ $ insertEntryStmt ->bindValue (6 , $ data [5 ]);
208
+ $ insertEntryStmt ->bindValue (7 , $ data [6 ]);
209
+ $ insertEntryStmt ->bindValue (8 , $ data [7 ]);
210
+ $ insertEntryStmt ->bindValue (9 , $ data [8 ]);
211
+ $ insertEntryStmt ->bindValue (10 , $ data [9 ]);
212
+ $ insertEntryStmt ->bindValue (11 , $ data [10 ]);
213
+ $ insertEntryStmt ->executeStatement ();
179
214
}
180
215
181
216
$ insertOidAncestorStmt = $ this ->connection ->prepare ('INSERT INTO acl_object_identity_ancestors (object_identity_id, ancestor_id) VALUES (?, ?) ' );
182
217
foreach ($ this ->getOidAncestorData () as $ data ) {
183
- $ insertOidAncestorStmt ->executeStatement ($ data );
218
+ $ insertOidAncestorStmt ->bindValue (1 , $ data [0 ]);
219
+ $ insertOidAncestorStmt ->bindValue (2 , $ data [1 ]);
220
+ $ insertOidAncestorStmt ->executeStatement ();
184
221
}
185
222
}
186
223
0 commit comments