public function it_do_not_authenticate_channel_when_cookie_name_is_missing(Session $session, ParameterBag $cookies)
 {
     $session->getName()->shouldBeCalled()->willReturn('session');
     $cookies->get('session')->shouldBeCalled()->willReturn('invalid_channel');
     $session->set('socketId', 1)->shouldNotBeCalled();
     $session->set('channelName', 'new_channel')->shouldNotBeCalled();
     $this->authenticate(1, 'new_channel')->shouldReturn(false);
 }
 /**
  * @Given I am logged in as :username
  */
 public function iAmAnLoggedInAs($username)
 {
     $session = new Session();
     $client = $this->getSession()->getDriver()->getClient();
     $client->getCookieJar()->set(new Cookie($session->getName(), $session->getId()));
     $session = $this->getContainer()->get('session');
     $user = $this->getKernel()->getContainer()->get('oauth2_server.test_bundle.end_user_manager')->getEndUserByUsername($username);
     if (null === $user) {
         throw new \Exception('Unknown user');
     }
     $token = new UsernamePasswordToken($user, 'secret', 'main', $user->getRoles());
     $session->set('_security_main', serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }