Skip to content

Commit 97aa0a8

Browse files
committed
Added environment-based Ldap server configuration for tests
1 parent b49079d commit 97aa0a8

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

Tests/Adapter/ExtLdap/AdapterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @requires extension ldap
2121
*/
22-
class AdapterTest extends \PHPUnit_Framework_TestCase
22+
class AdapterTest extends LdapTestCase
2323
{
2424
public function testLdapEscape()
2525
{
@@ -33,7 +33,7 @@ public function testLdapEscape()
3333
*/
3434
public function testLdapQuery()
3535
{
36-
$ldap = new Adapter(array('host' => 'localhost', 'port' => 3389));
36+
$ldap = new Adapter($this->getLdapConfig());
3737

3838
$ldap->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
3939
$query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))', array());

Tests/Adapter/ExtLdap/LdapManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
/**
2020
* @requires extension ldap
2121
*/
22-
class LdapManagerTest extends \PHPUnit_Framework_TestCase
22+
class LdapManagerTest extends LdapTestCase
2323
{
2424
/** @var Adapter */
2525
private $adapter;
2626

2727
protected function setUp()
2828
{
29-
$this->adapter = new Adapter(array('host' => 'localhost', 'port' => 3389));
29+
$this->adapter = new Adapter($this->getLdapConfig());
3030
$this->adapter->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
3131
}
3232

Tests/LdapTestCase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace Symfony\Component\Ldap\Tests;
4+
5+
class LdapTestCase extends \PHPUnit_Framework_TestCase
6+
{
7+
protected function getLdapConfig()
8+
{
9+
return array(
10+
'host' => getenv('LDAP_HOST'),
11+
'port' => getenv('LDAP_PORT'),
12+
);
13+
}
14+
}

phpunit.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
>
99
<php>
1010
<ini name="error_reporting" value="-1" />
11+
<env name="LDAP_HOST" value="127.0.0.1" />
12+
<env name="LDAP_PORT" value="3389" />
1113
</php>
1214

1315
<testsuites>

0 commit comments

Comments
 (0)