public function testLoginBeforeLoginReturningArray()
{
$user = ['id' => 1];
$event = new Event('event');
$event->result = $user;
$this->Trait->expects($this->at(0))->method('dispatchEvent')->with(UsersAuthComponent::EVENT_BEFORE_LOGIN)->will($this->returnValue($event));
$this->Trait->expects($this->at(1))->method('dispatchEvent')->with(UsersAuthComponent::EVENT_AFTER_LOGIN)->will($this->returnValue(new Event('name')));
$this->Trait->Auth = $this->getMockBuilder('Cake\\Controller\\Component\\AuthComponent')->setMethods(['setUser', 'redirectUrl'])->disableOriginalConstructor()->getMock();
$redirectLoginOK = '/';
$this->Trait->Auth->expects($this->once())->method('setUser')->with($user);
$this->Trait->Auth->expects($this->once())->method('redirectUrl')->will($this->returnValue($redirectLoginOK));
$this->Trait->expects($this->once())->method('redirect')->with($redirectLoginOK);
$this->Trait->login();
}