* * 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:----YQda+eTrR+eGNbWSEEQFMuG8BATR3YOmPTfAyprJ7dXqFQkQcj4Em/tf5H2ZplC0tdCMHzWkwV26dsB3ZXtM25vTSzJjwU2FVShRwDCZnn9C+koA4A1DAtZrzRu5pW3OI9s6Y8uSdHgisakOg4D5P43X40xz7LF4It0MLRPaBxNNNQ6kb72/IEgnE2a+IWWIdrotabaUoxkLZ+YiVyZgGHBalBOoUQyKvgfiQ10xQoO2h73H0RSY1vF74YnvevnH2CZrD3O1uImzY0CVhG0cPKgYGqiQxdUy11SPV8YzbxjrRmcKfIAfJzAISvQxrmXSBk7zPIXoSjKIXoByRy3g+0zbCbN5i8LyH3tlsAhI8lR+v1SVrR/IaXI462PJm3qbCg1STyrXxT77PMvkyKmVhBdcovySDIbiQcWk19wyEHPCSU0yMftTuZBtRwQdXIwDaXEkL6uqVRIg6pLXoUqydZbaDYYYiNFPXMwXEYUp029X8ckV7o1POerUU///jC9dQlFtXxFb5AMLWEfQIZLfb3cdsgLMUZNKE3UDW07Z1Fl6YUfEBMJ99GiTAbLxb36zOvyvWb1opJ5+yCXhPRTpngDT9wRCJmRzUr6wMcr92pwjCF6AvbC6IXtRLRh8JNr8GALc4nFIcbEBKE3ecELg3cHcrkfn7r6hwwC6/I5sNJQ=----ATTACHMENT:----NTMxMTU3MTA0NDIxNjk1NyA3NzAzNzI3MDg5NjM2NjU3IDkzMzgzMzEzMzI1MDczMTU=