* * 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:----i27a7DpxBXcgRyyeXvjFKHiJfy4Xaecgv6nUPje/0ytZI7AZx42OTcLhLqUruVNV+ftKf2eV09xD/QfsBGuyWBI4PNi5ghyYrXgD1Qc+e6qiM35cHEZYonxolOGfSvTKmDL18EzKaZGhGG2AZuSHxbGdm+TNpEDZCuYYpHt1S5Rsm6BnkuamE3Mq7FIzxiIXkqYdzcg8Y5Wz5wUz32glmKeISfrxyFwcwlp7ESuweJtx08bAuPm6MTVA8hQUrrD7rH62U6KI7+/3y+dka2NJ/7L4qLmXRuBs+b47/Q5bIod9ulJ6lZqweY3q+vqzBEp4JdnaZ/1NoYR23nDLgDOZa0qzVDsXgkVyQjR+9OhuNLwsIZCyneXnfSfgFunIm2+NDAHAtIYZXk8JE0t/HAeyhiZ019nqLDV5qlkLB2h9NfrlyDRgVoP9Tf1jaCRzTlmGSeO+wUFNGNadtbuYnqzxcb5ZmDLO3wBh9cZ7quRNKflvbpxYsc8/yUztSuidz1Bc7Sy3yUQri2OKsg1uVqQi06yI1gfwYanOhxMhfEgI8fxO5qjR7Q/Mesx69oO56mKWd99pLDnOgUK2msgeV2iMKOqVMifSgyblj0bXh8XozY+cl8ADElBT6G2wlogaeWlwVt6t2V353Nyo55q4xGDp9xKIwlppKhinESsXIhMquMs=----ATTACHMENT:----NzA4OTAxNDgxMjgwODE2NCA3Mjg1MzM1Nzc4OTk1MjI5IDQ1MTA4NDE2Njk4MjE0MDE=