Skip to content

Commit

Permalink
minor #19754 [DoctrineBridge] Fix exception message after misresolved…
Browse files Browse the repository at this point in the history
… merge (chalasr)

This PR was merged into the 2.8 branch.

Discussion
----------

[DoctrineBridge] Fix exception message after misresolved merge

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

b367d39 [DoctrineBridge] Fix exception message and tests after misresolved merge
  • Loading branch information
fabpot committed Aug 27, 2016
2 parents b05de7d + b367d39 commit 2980fb8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
Expand Up @@ -52,7 +52,7 @@ public function loadUserByUsername($username)
} 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);
Expand Down
Expand Up @@ -53,6 +53,32 @@ public function testLoadUserByUsername()
$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
*/
Expand Down Expand Up @@ -84,9 +110,9 @@ public function testLoadUserByUsernameWithUserProviderRepositoryAndWithoutProper

/**
* @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);
Expand Down

0 comments on commit 2980fb8

Please sign in to comment.