Skip to content

Commit e2f76c1

Browse files
committed
Use GithubAction to run ldap tests
1 parent 60cbcef commit e2f76c1

File tree

6 files changed

+13
-35
lines changed

6 files changed

+13
-35
lines changed

Tests/Adapter/ExtLdap/AdapterTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/**
2424
* @requires extension ldap
25+
* @group integration
2526
*/
2627
class AdapterTest extends LdapTestCase
2728
{
@@ -116,7 +117,7 @@ public function testLdapQueryScopeOneLevel()
116117

117118
public function testLdapPagination()
118119
{
119-
$ldap = new Adapter(array_merge($this->getLdapConfig()));
120+
$ldap = new Adapter($this->getLdapConfig());
120121
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
121122
$entries = $this->setupTestUsers($ldap);
122123

@@ -147,7 +148,7 @@ public function testLdapPagination()
147148
$this->assertEquals(\count($fully_paged_query->getResources()), 1);
148149
$this->assertEquals(\count($paged_query->getResources()), 5);
149150

150-
if (\PHP_MAJOR_VERSION > 7 || (\PHP_MAJOR_VERSION == 7 && \PHP_MINOR_VERSION >= 2)) {
151+
if (\PHP_VERSION_ID >= 70200) {
151152
// This last query is to ensure that we haven't botched the state of our connection
152153
// by not resetting pagination properly. extldap <= PHP 7.1 do not implement the necessary
153154
// bits to work around an implementation flaw, so we simply can't guarantee this to work there.
@@ -199,7 +200,7 @@ private function destroyEntries($ldap, $entries)
199200

200201
public function testLdapPaginationLimits()
201202
{
202-
$ldap = new Adapter(array_merge($this->getLdapConfig()));
203+
$ldap = new Adapter($this->getLdapConfig());
203204
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
204205

205206
$entries = $this->setupTestUsers($ldap);

Tests/Adapter/ExtLdap/LdapManagerTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,8 @@ public function testLdapAddDouble()
9696
$em->add($entry);
9797
try {
9898
$em->add($entry);
99-
} catch (LdapException $e) {
99+
} finally {
100100
$em->remove($entry);
101-
throw $e;
102101
}
103102
}
104103

@@ -215,12 +214,12 @@ public function testLdapRenameWithoutRemovingOldRdn()
215214
$newEntry = $result[0];
216215
$originalCN = $entry->getAttribute('cn')[0];
217216

218-
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
219-
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
220-
221-
$entryManager->rename($newEntry, 'cn='.$originalCN);
222-
223-
$this->executeSearchQuery(1);
217+
try {
218+
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
219+
$this->assertContains('Kevin', $newEntry->getAttribute('cn'));
220+
} finally {
221+
$entryManager->rename($newEntry, 'cn='.$originalCN);
222+
}
224223
}
225224

226225
public function testLdapAddRemoveAttributeValues()

Tests/Fixtures/conf/slapd.conf

Lines changed: 0 additions & 18 deletions
This file was deleted.

Tests/Fixtures/data/base.ldif

Lines changed: 0 additions & 4 deletions
This file was deleted.

Tests/LdapTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class LdapTestCase extends TestCase
99
protected function getLdapConfig()
1010
{
1111
$h = @ldap_connect(getenv('LDAP_HOST'), getenv('LDAP_PORT'));
12-
ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3);
12+
@ldap_set_option($h, LDAP_OPT_PROTOCOL_VERSION, 3);
1313

1414
if (!$h || !@ldap_bind($h)) {
1515
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
>
1111
<php>
1212
<ini name="error_reporting" value="-1" />
13-
<env name="LDAP_HOST" value="127.0.0.1" />
13+
<env name="LDAP_HOST" value="localhost" />
1414
<env name="LDAP_PORT" value="3389" />
1515
</php>
1616

0 commit comments

Comments
 (0)