15
15
use Symfony \Component \Ldap \Adapter \ExtLdap \Collection ;
16
16
use Symfony \Component \Ldap \Adapter \ExtLdap \UpdateOperation ;
17
17
use Symfony \Component \Ldap \Entry ;
18
- use Symfony \Component \Ldap \Exception \AlreadyExistsException ;
19
18
use Symfony \Component \Ldap \Exception \LdapException ;
20
19
use Symfony \Component \Ldap \Exception \NotBoundException ;
21
20
use Symfony \Component \Ldap \Exception \UpdateOperationException ;
22
21
use Symfony \Component \Ldap \Tests \LdapTestCase ;
23
22
24
23
/**
25
24
* @requires extension ldap
25
+ * @group integration
26
26
*/
27
27
class LdapManagerTest extends LdapTestCase
28
28
{
@@ -82,7 +82,7 @@ public function testLdapAddInvalidEntry()
82
82
*/
83
83
public function testLdapAddDouble ()
84
84
{
85
- $ this ->expectException (AlreadyExistsException ::class);
85
+ $ this ->expectException (LdapException ::class);
86
86
$ this ->executeSearchQuery (1 );
87
87
88
88
$ entry = new Entry ('cn=Elsa Amrouche,dc=symfony,dc=com ' , [
@@ -94,7 +94,12 @@ public function testLdapAddDouble()
94
94
95
95
$ em = $ this ->adapter ->getEntryManager ();
96
96
$ em ->add ($ entry );
97
- $ em ->add ($ entry );
97
+ try {
98
+ $ em ->add ($ entry );
99
+ } catch (LdapException $ e ) {
100
+ $ em ->remove ($ entry );
101
+ throw $ e ;
102
+ }
98
103
}
99
104
100
105
/**
@@ -210,7 +215,8 @@ public function testLdapRenameWithoutRemovingOldRdn()
210
215
$ newEntry = $ result [0 ];
211
216
$ originalCN = $ entry ->getAttribute ('cn ' )[0 ];
212
217
213
- $ this ->assertStringContainsString ($ originalCN , $ newEntry ->getAttribute ('cn ' ));
218
+ $ this ->assertContains ($ originalCN , $ newEntry ->getAttribute ('cn ' ));
219
+ $ this ->assertContains ('Kevin ' , $ newEntry ->getAttribute ('cn ' ));
214
220
215
221
$ entryManager ->rename ($ newEntry , 'cn= ' .$ originalCN );
216
222
@@ -372,13 +378,16 @@ public function testLdapMove()
372
378
$ result = $ this ->executeSearchQuery (1 );
373
379
374
380
$ entry = $ result [0 ];
375
- $ this ->assertNotContains ('ou=Ldap ' , $ entry ->getDn ());
381
+ $ this ->assertStringNotContainsString ('ou=Ldap ' , $ entry ->getDn ());
376
382
377
383
$ entryManager = $ this ->adapter ->getEntryManager ();
378
384
$ entryManager ->move ($ entry , 'ou=Ldap,ou=Components,dc=symfony,dc=com ' );
379
385
380
386
$ result = $ this ->executeSearchQuery (1 );
381
387
$ movedEntry = $ result [0 ];
382
388
$ this ->assertStringContainsString ('ou=Ldap ' , $ movedEntry ->getDn ());
389
+
390
+ // Move back entry
391
+ $ entryManager ->move ($ movedEntry , 'dc=symfony,dc=com ' );
383
392
}
384
393
}
0 commit comments