Skip to content

Commit 434ef5b

Browse files
Merge branch '2.8' into 3.1
* 2.8: [VarDumper] Various minor fixes & cleanups Revert "bug #18935 [Form] Consider a violation even if the form is not submitted (egeloen)" [HttpKernel] Add missing SsiFragmentRendererTest [DoctrineBridge] Fix exception message and tests after misresolved merge Fixes the calendar in constructor to handle null
2 parents bad5abf + 231453d commit 434ef5b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

Security/User/EntityUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function loadUserByUsername($username)
5151
$user = $repository->findOneBy(array($this->property => $username));
5252
} else {
5353
if (!$repository instanceof UserLoaderInterface) {
54-
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)));
54+
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)));
5555
}
5656

5757
$user = $repository->loadUserByUsername($username);

Tests/Security/User/EntityUserProviderTest.php

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

56+
public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty()
57+
{
58+
$user = new User(1, 1, 'user1');
59+
60+
$repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')
61+
->disableOriginalConstructor()
62+
->getMock();
63+
$repository
64+
->expects($this->once())
65+
->method('loadUserByUsername')
66+
->with('user1')
67+
->willReturn($user);
68+
69+
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
70+
->disableOriginalConstructor()
71+
->getMock();
72+
$em
73+
->expects($this->once())
74+
->method('getRepository')
75+
->with('Symfony\Bridge\Doctrine\Tests\Fixtures\User')
76+
->willReturn($repository);
77+
78+
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User');
79+
$this->assertSame($user, $provider->loadUserByUsername('user1'));
80+
}
81+
5682
/**
5783
* @expectedException \InvalidArgumentException
58-
* @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.
84+
* @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.
5985
*/
60-
public function testLoadUserByUsernameWithNonUserProviderRepositoryAndWithoutProperty()
86+
public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty()
6187
{
6288
$em = DoctrineTestHelper::createTestEntityManager();
6389
$this->createSchema($em);

0 commit comments

Comments
 (0)