Inheritance: extends BaseContext
Exemplo n.º 1
0
 /**
  * @Given I am authenticated as :username
  * @param string $username
  */
 public function iAmAuthenticatedAs($username)
 {
     $jwManager = $this->getService('lexik_jwt_authentication.jwt_manager');
     $userRepository = $this->getService('doctrine')->getRepository('AppBundle:Core\\User');
     $user = $userRepository->findOneBy(['username' => $username]);
     if ($user === null) {
         throw new \Exception(sprintf('User with username "%s" do not exists', $username));
     }
     $token = $jwManager->create($user);
     $this->restContext->iAddHeaderEqualToValue('AUTHORIZATION', 'Bearer ' . $token);
 }
Exemplo n.º 2
0
 /**
  * @Then I set header :name to :value
  */
 public function iAddHeaderEqualTo($name, $value)
 {
     $this->headers[] = $name;
     parent::iAddHeaderEqualTo($name, $value);
 }