8000 [DoctrineBridge] Fix exception message and tests after misresolved merge · symfony/symfony@437e0cb · GitHub
[go: up one dir, main page]

Skip to content

Commit 437e0cb

Browse files
committed
[DoctrineBridge] Fix exception message and tests after misresolved merge
1 parent b05de7d commit 437e0cb

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function loadUserByUsername($username)
5252
} else {
5353
if (!$repository instanceof UserLoaderInterface) {
5454
if (!$repository instanceof UserProviderInterface) {
55-
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Component\Security\Core\User\UserProviderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_class($repository)));
55+
throw new \InvalidArgumentException(sprintf('You must either make the "%s" entity Doctrine Repository ("%s") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.', $this->classOrAlias, get_class($repository)));
5656
}
5757

5858
@trigger_error('Implementing loadUserByUsername from Symfony\Component\Security\Core\User\UserProviderInterface is deprecated since version 2.8 and will be removed in 3.0. Implement the Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface instead.', E_USER_DEPRECATED);

src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,35 @@ public function testLoadUserByUsername()
5353
$this->assertSame($user, $provider->loadUserByUsername('user1'));
5454
}
5555

56+
/**
57+
* @group legacy
58+
*/
59+
public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty()
60+
{
61+
$user = new User(1, 1, 'user1');
62+
63+
$repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')
64+
->disableOriginalConstructor()
65+
->getMock();
66+
$repository
67+
->expects($this->once())
68+
->method('loadUserByUsername')
69+
->with('user1')
70+
->willReturn($user);
71+
72+
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
73+
->disableOriginalConstructor()
74+
->getMock();
75+
$em
76+
->expects($this->once())
77+
->method('getRepository')
78+
->with('Symfony\Bridge\Doctrine\Tests\Fixtures\User')
79+
->willReturn($repository);
80+
81+
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User');
82+
$this->assertSame($user, $provider->loadUserByUsername('user1'));
83+
}
84+
5685
/**
5786
* @group legacy
5887
*/
@@ -84,9 +113,9 @@ public function testLoadUserByUsernameWithUserProviderRepositoryAndWithoutProper
84113

85114
/**
86115
* @expectedException \InvalidArgumentException
87-
* @expectedExceptionMessage You must either make the "Symfony\Bridge\Doctrine\Tests\Fixtures\User" entity Doctrine Repository ("Doctrine\ORM\EntityRepository") implement "Symfony\Component\Security\Core\User\UserProviderInterface" or set the "property" option in the corresponding entity provider configuration.
116+
* @expectedExceptionMessage You must either make the "Symfony\Bridge\Doctrine\Tests\Fixtures\User" entity Doctrine Repository ("Doctrine\ORM\EntityRepository") implement "Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface" or set the "property" option in the corresponding entity provider configuration.
88117
*/
89-
public function testLoadUserByUsernameWithNonUserProviderRepositoryAndWithoutProperty()
118+
public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty()
90119
{
91120
$em = DoctrineTestHelper::createTestEntityManager();
92121
$this->createSchema($em);

0 commit comments

Comments
 (0)
0