8000 Added tests to check unbound exception · symfony/symfony@3c2c3ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c2c3ba

Browse files
Added tests to check unbound exception
1 parent c87c3fd commit 3c2c3ba

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/AdapterTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Ldap\Adapter\ExtLdap\Adapter;
1515
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
1616
use Symfony\Component\Ldap\Entry;
17+
use Symfony\Component\Ldap\Exception\NotBoundException;
1718
use Symfony\Component\Ldap\LdapInterface;
1819

1920
/**
@@ -65,4 +66,15 @@ public function testLdapQueryIterator()
6566
$this->assertEquals(array('Fabien Potencier'), $entry->getAttribute('cn'));
6667
$this->assertEquals(array('fabpot@symfony.com', 'fabien@potencier.com'), $entry->getAttribute('mail'));
6768
}
69+
70+
/**
71+
* @group functional
72+
*/
73+
public function testLdapQueryWithoutBind()
74+
{
75+
$ldap = new Adapter($this->getLdapConfig());
76+
$this->setExpectedException(NotBoundException::class);
77+
$query = $ldap->createQuery('dc=symfony,dc=com', '(&(objectclass=person)(ou=Maintainers))', array());
78+
$query->execute();
79+
}
6880
}

src/Symfony/Component/Ldap/Tests/Adapter/ExtLdap/LdapManagerTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Ldap\Adapter\ExtLdap\Collection;
1616
use Symfony\Component\Ldap\Entry;
1717
use Symfony\Component\Ldap\Exception\LdapException;
18+
use Symfony\Component\Ldap\Exception\NotBoundException;
1819

1920
/**
2021
* @requires extension ldap
@@ -98,6 +99,39 @@ public function testLdapUpdate()
9899
$this->assertNull($entry->getAttribute('email'));
99100
}
100101

102+
/**
103+
* @group functional
104+
*/
105+
public function testLdapUnboundAdd()
106+
{
107+
$this->adapter = new Adapter($this->getLdapConfig());
108+
$this->setExpectedException(NotBoundException::class);
109+
$em = $this->adapter->getEntryManager();
110+
$em->add(new Entry(''));
111+
}
112+
113+
/**
114+
* @group functional
115+
*/
116+
public function testLdapUnboundRemove()
117+
{
118+
$this->adapter = new Adapter($this->getLdapConfig());
119+
$this->setExpectedException(NotBoundException::class);
120+
$em = $this->adapter->getEntryManager();
121+
$em->remove(new Entry(''));
122+
}
123+
124+
/**
125+
* @group functional
126+
*/
127+
public function testLdapUnboundUpdate()
128+
{
129+
$this->adapter = new Adapter($this->getLdapConfig());
130+
$this->setExpectedException(NotBoundException::class);
131+
$em = $this->adapter->getEntryManager();
132+
$em->update(new Entry(''));
133+
}
134+
101135
/**
102136
* @return Collection|Entry[]
103137
*/

0 commit comments

Comments
 (0)
0