Skip to content

Commit 0eaf329

Browse files
committed
minor symfony#17911 [Ldap] Added environment-based Ldap server configuration for tests (csarrazi)
This PR was merged into the 3.1-dev branch. Discussion ---------- [Ldap] Added environment-based Ldap server configuration for tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | This PR makes Ldap server host and port configurable by using environment variables. This enables a developer to test the Ldap component locally, or on a vagrant virtual machine, depending on the use case. If one wishes to run the tests against his own Ldap server, one simply needs to use the `LDAP_HOST` and `LDAP_PORT` environment variables when running the `phpunit` command. Commits ------- d0fbaea Added environment-based Ldap server configuration for tests
2 parents db07500 + d0fbaea commit 0eaf329

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

phpunit.xml.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
<ini name="memory_limit" value="-1" />
1414
<env name="DUMP_LIGHT_ARRAY" value="" />
1515
<env name="DUMP_STRING_LENGTH" value="" />
16+
<env name="LDAP_HOST" value="127.0.0.1" />
17+
<env name="LDAP_PORT" value="3389" />
1618
</php>
1719

1820
<testsuites>

src/Symfony/Component/Ldap/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());

src/Symfony/Component/Ldap/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

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+
}

src/Symfony/Component/Ldap/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)