8000 minor #19754 [DoctrineBridge] Fix exception message after misresolved… · symfony/symfony@2980fb8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2980fb8

Browse files
committed
minor #19754 [DoctrineBridge] Fix exception message after misresolved 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
2 parents b05de7d + b367d39 commit 2980fb8

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-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: 28 additions & 2 deletions
< 8000 td data-grid-cell-id="diff-ab19a94f8b50d40d8bc510de5ae6eca5944ee475ad14e63094e2f8d16da3d9ee-55-78-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-additionNum-bgColor, var(--diffBlob-addition-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,32 @@ 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
* @group legacy
5884
*/
@@ -84,9 +110,9 @@ public function testLoadUserByUsernameWithUserProviderRepositoryAndWithoutProper
84110

85111
/**
86112
* @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.
113+
* @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.
88114
*/
89-
public function testLoadUserByUsernameWithNonUserProviderRepositoryAndWithoutProperty()
115+
public function testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty()
90116
{
91117
$em = DoctrineTestHelper::createTestEntityManager();
92118
$this->createSchema($em);

0 commit comments

Comments
 (0)
0