[DoctrineBridge] Fix exception message and tests after misresolved merge
This commit is contained in:
parent
b05de7d2be
commit
b367d39841
@ -52,7 +52,7 @@ class EntityUserProvider implements UserProviderInterface
|
||||
} else {
|
||||
if (!$repository instanceof UserLoaderInterface) {
|
||||
if (!$repository instanceof UserProviderInterface) {
|
||||
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)));
|
||||
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)));
|
||||
}
|
||||
|
||||
@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);
|
||||
|
@ -53,6 +53,32 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($user, $provider->loadUserByUsername('user1'));
|
||||
}
|
||||
|
||||
public function testLoadUserByUsernameWithUserLoaderRepositoryAndWithoutProperty()
|
||||
{
|
||||
$user = new User(1, 1, 'user1');
|
||||
|
||||
$repository = $this->getMockBuilder('Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$repository
|
||||
->expects($this->once())
|
||||
->method('loadUserByUsername')
|
||||
->with('user1')
|
||||
->willReturn($user);
|
||||
|
||||
$em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$em
|
||||
->expects($this->once())
|
||||
->method('getRepository')
|
||||
->with('Symfony\Bridge\Doctrine\Tests\Fixtures\User')
|
||||
->willReturn($repository);
|
||||
|
||||
$provider = new EntityUserProvider($this->getManager($em), 'Symfony\Bridge\Doctrine\Tests\Fixtures\User');
|
||||
$this->assertSame($user, $provider->loadUserByUsername('user1'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
@ -84,9 +110,9 @@ class EntityUserProviderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
* @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.
|
||||
* @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.
|
||||
*/
|
||||
public function testLoadUserByUsernameWithNonUserProviderRepositoryAndWithoutProperty()
|
||||
public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty()
|
||||
{
|
||||
$em = DoctrineTestHelper::createTestEntityManager();
|
||||
$this->createSchema($em);
|
||||
|
Reference in New Issue
Block a user