|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Security\Core\Tests\User; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\Security\Core\User\ChainUserChecker; |
| 16 | +use Symfony\Component\Security\Core\User\UserCheckerInterface; |
| 17 | +use Symfony\Component\Security\Core\User\UserInterface; |
| 18 | + |
| 19 | +final class ChainUserCheckerTest extends TestCase |
| 20 | +{ |
| 21 | + public function testForwardsPreAuthToAllUserCheckers() |
| 22 | + { |
| 23 | + $user = $this->createMock(UserInterface::class); |
| 24 | + |
| 25 | + $checker1 = $this->createMock(UserCheckerInterface::class); |
| 26 | + $checker1->expects($this->once()) |
| 27 | + ->method('checkPreAuth') |
| 28 | + ->with($user); |
| 29 | + |
| 30 | + $checker2 = $this->createMock(UserCheckerInterface::class); |
| 31 | + $checker2->expects($this->once()) |
| 32 | + ->method('checkPreAuth') |
| 33 | + ->with($user); |
| 34 | + |
| 35 | + $checker3 = $this->createMock(UserCheckerInterface::class); |
| 36 | + $checker3->expects($this->once()) |
| 37 | + ->method('checkPreAuth') |
| 38 | + ->with($user); |
| 39 | + |
| 40 | + (new ChainUserChecker([$checker1, $checker2, $checker3]))->checkPreAuth($user); |
| 41 | + } |
| 42 | + |
| 43 | + public function testForwardsPostAuthToAllUserCheckers() |
| 44 | + { |
| 45 | + $user = $this->createMock(UserInterface::class); |
| 46 | + |
| 47 | + $checker1 = $this->createMock(UserCheckerInterface::class); |
| 48 | + $checker1->expects($this->once()) |
| 49 | + ->method('checkPostAuth') |
| 50 | + ->with($user); |
| 51 | + |
| 52 | + $checker2 = $this->createMock(UserCheckerInterface::class); |
| 53 | + $checker2->expects($this->once()) |
| 54 | + ->method('checkPostAuth') |
| 55 | + ->with($user); |
| 56 | + |
| 57 | + $checker3 = $this->createMock(UserCheckerInterface::class); |
| 58 | + $checker3->expects($this->once()) |
| 59 | + ->method('checkPostAuth') |
| 60 | + ->with($user); |
| 61 | + |
| 62 | + (new ChainUserChecker([$checker1, $checker2, $checker3]))->checkPostAuth($user); |
| 63 | + } |
| 64 | +} |
0 commit comments