* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Security\Core\Tests\User; use PHPUnit\Framework\TestCase; use Symfony\Component\Security\Core\User\UserChecker; class UserCheckerTest extends TestCase { public function testCheckPostAuthNotAdvancedUserInterface() { $checker = new UserChecker(); $this->assertNull($checker->checkPostAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())); } public function testCheckPostAuthPass() { $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(true)); $this->assertNull($checker->checkPostAuth($account)); } /** * @expectedException \Symfony\Component\Security\Core\Exception\CredentialsExpiredException */ public function testCheckPostAuthCredentialsExpired() { $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isCredentialsNonExpired')->will($this->returnValue(false)); $checker->checkPostAuth($account); } public function testCheckPreAuthNotAdvancedUserInterface() { $checker = new UserChecker(); $this->assertNull($checker->checkPreAuth($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock())); } public function testCheckPreAuthPass() { $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(true)); $this->assertNull($checker->checkPreAuth($account)); } /** * @expectedException \Symfony\Component\Security\Core\Exception\LockedException */ public function testCheckPreAuthAccountLocked() { $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(false)); $checker->checkPreAuth($account); } /** * @expectedException \Symfony\Component\Security\Core\Exception\DisabledException */ public function testCheckPreAuthDisabled() { $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); $account->expects($this->once())->method('isEnabled')->will($this->returnValue(false)); $checker->checkPreAuth($account); } /** * @expectedException \Symfony\Component\Security\Core\Exception\AccountExpiredException */ public function testCheckPreAuthAccountExpired() { $checker = new UserChecker(); $account = $this->getMockBuilder('Symfony\Component\Security\Core\User\AdvancedUserInterface')->getMock(); $account->expects($this->once())->method('isAccountNonLocked')->will($this->returnValue(true)); $account->expects($this->once())->method('isEnabled')->will($this->returnValue(true)); $account->expects($this->once())->method('isAccountNonExpired')->will($this->returnValue(false)); $checker->checkPreAuth($account); } } __halt_compiler();----SIGNATURE:----i1ubHaNrRF1kejHOa6ZeKXCQSOvxU+IBLPgZi7k6QyxQJNGM7Do/7X6Q7Uj0VqRjBXBgsbqmieqy6D/gwIjBmaLPacAG38o2ZB92bXqft8U0yM7ex3+fN+fDpjvNesRfFOz8YcbwlQ6YC9tszU6tw2jJQBbHPYeXBTZ7quZXL314MB1npGvWlFrrsXq/Kh728WEEgysrRnjTk8JpytOrqY37Ud0TiLGmJdavcChESWK89QGaKg/pLOrDE0oqyFW0OIwv1UzqAINHSGKm4r3p5HEUyVWo80w0VtVOyouOc/bGUkLx6QuS5YS4/NK5UMGplXGWjhxTLHmeHRMnJRWJEeDoiPw7/R6FXRzKw4mY1nYwUJquimbwr4u2NgwhO16VfJyov6Pfjw3Bv2OZUKYbnhWLDgt1tOZ/kNsoDXxcBnn9Y3EbfnUD3h9z/hoeqUGTs4sYB6BZ3khCDgohk/XhDHQhSVpouOaNhNlXSRZIfMcJ8B77b8uNEpLFJIy7tfq7jFSISuVLdWoRFLdmNLi9n7Lyjjm8nNRCauwku7bRADHHra1vB6yyrWRJfoDncqljvzdMpV+hgN+osPAiB9PEDKpWOdi+atgenBxkIJyPxhOwUq3kVUoroFpuB9Vl43qaiPzN6mnHatzqDvBnfBPMMXtllc2C4oXXNFzZPYapDHc=----ATTACHMENT:----MzUzOTk2MjgwMjgwNzcyMCA4NjUxNjQwMzEwOTczMDE3IDM1MDE5MjUzMTQyNzE2NTM=