Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 394be3e

Browse filesBrowse files
committed
minor #58303 Miscellaneous tests improvements (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- Miscellaneous tests improvements | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Mainly missed occasions to use `assertCount()` and wrong arguments placement between expected and actual results. Also for `AbstractDivLayoutTestCase` the abstract class references data provider only defined in the subclass. I think it's a good idea to put the data providers next to the test methods instead. Commits ------- 94c43b4fbe Miscellaneous tests improvements
2 parents 24569f0 + f6965c0 commit 394be3e
Copy full SHA for 394be3e

File tree

Expand file treeCollapse file tree

1 file changed

+18
-27
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-27
lines changed

‎Tests/Adapter/ExtLdap/AdapterTest.php

Copy file name to clipboardExpand all lines: Tests/Adapter/ExtLdap/AdapterTest.php
+18-27Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -160,43 +160,37 @@ public function testLdapPagination()
160160
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
161161
$entries = $this->setupTestUsers($ldap);
162162

163-
$unpaged_query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
163+
$unpagedQuery = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
164164
'scope' => Query::SCOPE_ONE,
165165
]);
166-
$fully_paged_query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
166+
$fullyPagedQuery = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
167167
'scope' => Query::SCOPE_ONE,
168168
'pageSize' => 25,
169169
]);
170-
$paged_query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
170+
$pagedQuery = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
171171
'scope' => Query::SCOPE_ONE,
172172
'pageSize' => 5,
173173
]);
174174

175175
try {
176-
$unpaged_results = $unpaged_query->execute();
177-
$fully_paged_results = $fully_paged_query->execute();
178-
$paged_results = $paged_query->execute();
179-
180176
// All four of the above queries should result in the 25 'users' being returned
181-
$this->assertEquals($unpaged_results->count(), 25);
182-
$this->assertEquals($fully_paged_results->count(), 25);
183-
$this->assertEquals($paged_results->count(), 25);
177+
$this->assertCount(25, $unpagedQuery->execute());
178+
$this->assertCount(25, $fullyPagedQuery->execute());
179+
$this->assertCount(25, $pagedQuery->execute());
184180

185181
// They should also result in 1 or 25 / pageSize results
186-
$this->assertEquals(\count($unpaged_query->getResources()), 1);
187-
$this->assertEquals(\count($fully_paged_query->getResources()), 1);
188-
$this->assertEquals(\count($paged_query->getResources()), 5);
182+
$this->assertCount(1, $unpagedQuery->getResources());
183+
$this->assertCount(1, $fullyPagedQuery->getResources());
184+
$this->assertCount(5, $pagedQuery->getResources());
189185

190186
// This last query is to ensure that we haven't botched the state of our connection
191187
// by not resetting pagination properly.
192-
$final_query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
188+
$finalQuery = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
193189
'scope' => Query::SCOPE_ONE,
194190
]);
195191

196-
$final_results = $final_query->execute();
197-
198-
$this->assertEquals($final_results->count(), 25);
199-
$this->assertEquals(\count($final_query->getResources()), 1);
192+
$this->assertCount(25, $finalQuery->execute());
193+
$this->assertCount(1, $finalQuery->getResources());
200194
} catch (LdapException $exc) {
201195
$this->markTestSkipped('Test LDAP server does not support pagination');
202196
}
@@ -241,26 +235,23 @@ public function testLdapPaginationLimits()
241235

242236
$entries = $this->setupTestUsers($ldap);
243237

244-
$low_max_query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
238+
$lowMaxQuery = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
245239
'scope' => Query::SCOPE_ONE,
246240
'pageSize' => 10,
247241
'maxItems' => 5,
248242
]);
249-
$high_max_query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
243+
$highMaxQuery = $ldap->createQuery('dc=symfony,dc=com', '(&(objectClass=applicationProcess)(cn=user*))', [
250244
'scope' => Query::SCOPE_ONE,
251245
'pageSize' => 10,
252246
'maxItems' => 13,
253247
]);
254248

255249
try {
256-
$low_max_results = $low_max_query->execute();
257-
$high_max_results = $high_max_query->execute();
258-
259-
$this->assertEquals($low_max_results->count(), 5);
260-
$this->assertEquals($high_max_results->count(), 13);
250+
$this->assertCount(5, $lowMaxQuery->execute());
251+
$this->assertCount(13, $highMaxQuery->execute());
261252

262-
$this->assertEquals(\count($low_max_query->getResources()), 1);
263-
$this->assertEquals(\count($high_max_query->getResources()), 2);
253+
$this->assertCount(1, $lowMaxQuery->getResources());
254+
$this->assertCount(2, $highMaxQuery->getResources());
264255
} catch (LdapException $exc) {
265256
$this->markTestSkipped('Test LDAP server does not support pagination');
266257
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.