| Total Complexity | 4 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Coverage | 63.64% |
| Changes | 0 | ||
| 1 | <?php |
||
| 5 | trait TesterTrait |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * @var string[] pairs of user_name => oauth2_token for oauth2 auth. |
||
| 9 | */ |
||
| 10 | protected static array $tokens = []; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var string identificator for the auth/logged user. |
||
| 14 | */ |
||
| 15 | protected string $loggedUsername; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Saves a token and user by an unique name. |
||
| 19 | * |
||
| 20 | * @param string $tokenName unique name to index the tokens and models |
||
| 21 | * @param string $token oauth2 authorization token |
||
| 22 | */ |
||
| 23 | public function storeToken(string $tokenName, string $token) |
||
| 24 | { |
||
| 25 | static::$tokens[$tokenName] = $token; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Authenticates a user stored in `$tokens` |
||
| 30 | * |
||
| 31 | * @param string $tokenName |
||
| 32 | */ |
||
| 33 | public function amAuthByToken(string $tokenName) |
||
| 34 | { |
||
| 35 | $this->amBearerAuthenticated(static::$tokens[$tokenName]); |
||
|
|
|||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Checks over the HTTP pagination headers and (optionally) its values. |
||
| 40 | */ |
||
| 41 | 2 | public function seePaginationHttpHeaders() |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Checks over the HTTP content type header value. |
||
| 51 | */ |
||
| 52 | 10 | public function seeContentTypeHttpHeader( |
|
| 58 |