public function test_auth_passes($credentials = null)
{
$credentials = $credentials ?: ['email' => '[email protected]', 'password' => '12345'];
$user = $this->getMockUser(['cn' => '', 'mail' => '[email protected]', 'samaccountname' => 'jdoe', 'objectsid' => 'S-1-5-32-544']);
$connection = $this->getMockConnection();
$connection->expects($this->exactly(1))->method('isBound')->willReturn(true);
$connection->expects($this->exactly(1))->method('search')->willReturn('resource');
$connection->expects($this->exactly(1))->method('getEntries')->willReturn(['count' => 1, $user->getAttributes()]);
$connection->expects($this->exactly(2))->method('bind')->with($this->logicalOr($this->equalTo('jdoe'), $this->equalTo('admin')))->willReturn(true);
Event::shouldReceive('fire')->atLeast()->times(4)->withAnyArgs();
$this->assertTrue(Auth::attempt($credentials));
$user = Auth::user();
$this->assertInstanceOf(User::class, $user);
$this->assertEquals($credentials['email'], $user->mail[0]);
}