Skip to content

Commit 1d71613

Browse files
Merge branch '4.4' into 5.1
* 4.4: Use createMock() and use import instead of FQCN
2 parents b994c8f + aa4597d commit 1d71613

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Tests/Adapter/ExtLdap/EntryManagerTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
use Symfony\Component\Ldap\Adapter\ExtLdap\Connection;
1515
use Symfony\Component\Ldap\Adapter\ExtLdap\EntryManager;
1616
use Symfony\Component\Ldap\Entry;
17+
use Symfony\Component\Ldap\Exception\LdapException;
18+
use Symfony\Component\Ldap\Exception\NotBoundException;
1719

1820
class EntryManagerTest extends TestCase
1921
{
2022
public function testMove()
2123
{
22-
$this->expectException(\Symfony\Component\Ldap\Exception\LdapException::class);
24+
$this->expectException(LdapException::class);
2325
$this->expectExceptionMessage('Entry "$$$$$$" malformed, could not parse RDN.');
2426
$connection = $this->createMock(Connection::class);
2527
$connection
@@ -33,9 +35,9 @@ public function testMove()
3335

3436
public function testGetResources()
3537
{
36-
$this->expectException(\Symfony\Component\Ldap\Exception\NotBoundException::class);
38+
$this->expectException(NotBoundException::class);
3739
$this->expectExceptionMessage('Query execution is not possible without binding the connection first.');
38-
$connection = $this->getMockBuilder(Connection::class)->getMock();
40+
$connection = $this->createMock(Connection::class);
3941
$connection
4042
->expects($this->once())
4143
->method('isBound')->willReturn(false);

Tests/LdapTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ class LdapTest extends TestCase
2929

3030
protected function setUp(): void
3131
{
32-
$this->adapter = $this->getMockBuilder(AdapterInterface::class)->getMock();
32+
$this->adapter = $this->createMock(AdapterInterface::class);
3333
$this->ldap = new Ldap($this->adapter);
3434
}
3535

3636
public function testLdapBind()
3737
{
38-
$connection = $this->getMockBuilder(ConnectionInterface::class)->getMock();
38+
$connection = $this->createMock(ConnectionInterface::class);
3939
$connection
4040
->expects($this->once())
4141
->method('bind')

Tests/Security/LdapUserProviderTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Symfony\Component\Ldap\LdapInterface;
2020
use Symfony\Component\Ldap\Security\LdapUser;
2121
use Symfony\Component\Ldap\Security\LdapUserProvider;
22+
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
23+
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
2224

2325
/**
2426
* @requires extension ldap
@@ -27,7 +29,7 @@ class LdapUserProviderTest extends TestCase
2729
{
2830
public function testLoadUserByUsernameFailsIfCantConnectToLdap()
2931
{
30-
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
32+
$this->expectException(UsernameNotFoundException::class);
3133

3234
$ldap = $this->createMock(LdapInterface::class);
3335
$ldap
@@ -42,7 +44,7 @@ public function testLoadUserByUsernameFailsIfCantConnectToLdap()
4244

4345
public function testLoadUserByUsernameFailsIfNoLdapEntries()
4446
{
45-
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
47+
$this->expectException(UsernameNotFoundException::class);
4648

4749
$result = $this->createMock(CollectionInterface::class);
4850
$query = $this->createMock(QueryInterface::class);
@@ -74,7 +76,7 @@ public function testLoadUserByUsernameFailsIfNoLdapEntries()
7476

7577
public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
7678
{
77-
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
79+
$this->expectException(UsernameNotFoundException::class);
7880

7981
$result = $this->createMock(CollectionInterface::class);
8082
$query = $this->createMock(QueryInterface::class);
@@ -106,7 +108,7 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
106108

107109
public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
108110
{
109-
$this->expectException(\Symfony\Component\Security\Core\Exception\InvalidArgumentException::class);
111+
$this->expectException(InvalidArgumentException::class);
110112

111113
$result = $this->createMock(CollectionInterface::class);
112114
$query = $this->createMock(QueryInterface::class);
@@ -183,7 +185,7 @@ public function testLoadUserByUsernameShouldNotFailIfEntryHasNoUidKeyAttribute()
183185

184186
public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
185187
{
186-
$this->expectException(\Symfony\Component\Security\Core\Exception\InvalidArgumentException::class);
188+
$this->expectException(InvalidArgumentException::class);
187189

188190
$result = $this->createMock(CollectionInterface::class);
189191
$query = $this->createMock(QueryInterface::class);

0 commit comments

Comments
 (0)