/**
  * @param array $payload
  *
  * @return AuthenticationEvent
  */
 public static function createAuthenticationEvent(array $payload)
 {
     $optin = Optin::create($payload['optin']);
     $senderId = $payload['sender']['id'];
     $recipientId = $payload['recipient']['id'];
     $timestamp = $payload['timestamp'];
     return new AuthenticationEvent($senderId, $recipientId, $timestamp, $optin);
 }
 function it_create_an_authentication_event()
 {
     $raw = '
         {
           "sender":{
             "id":"USER_ID"
           },
           "recipient":{
             "id":"PAGE_ID"
           },
           "timestamp":1234567890,
           "optin":{
             "ref":"PASS_THROUGH_PARAM"
           }
         } 
     ';
     $arr = json_decode($raw, true);
     $expectedEvent = new AuthenticationEvent('USER_ID', 'PAGE_ID', 1234567890, Optin::create($arr['optin']));
     $event = $this::createAuthenticationEvent($arr);
     $event->shouldBeLike($expectedEvent);
     $event2 = $this::create($arr);
     $event2->shouldBeLike($expectedEvent);
 }