ROAResearch /
yii2-roa
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace roaresearch\yii2\roa\test; |
||||||
| 4 | |||||||
| 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]); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 36 | } |
||||||
| 37 | |||||||
| 38 | /** |
||||||
| 39 | * Checks over the HTTP pagination headers and (optionally) its values. |
||||||
| 40 | */ |
||||||
| 41 | 2 | public function seePaginationHttpHeaders() |
|||||
| 42 | { |
||||||
| 43 | 2 | $this->seeHttpHeaderOnce('X-Pagination-Total-Count'); |
|||||
|
0 ignored issues
–
show
It seems like
seeHttpHeaderOnce() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 44 | 2 | $this->seeHttpHeaderOnce('X-Pagination-Page-Count'); |
|||||
| 45 | 2 | $this->seeHttpHeaderOnce('X-Pagination-Current-Page'); |
|||||
| 46 | 2 | $this->seeHttpHeaderOnce('X-Pagination-Per-Page'); |
|||||
| 47 | } |
||||||
| 48 | |||||||
| 49 | /** |
||||||
| 50 | * Checks over the HTTP content type header value. |
||||||
| 51 | */ |
||||||
| 52 | 10 | public function seeContentTypeHttpHeader( |
|||||
| 53 | string $contentType = Tester::HAL_JSON_CONTENT_TYPE |
||||||
| 54 | ) { |
||||||
| 55 | 10 | $this->seeHttpHeader('Content-Type', $contentType); |
|||||
|
0 ignored issues
–
show
It seems like
seeHttpHeader() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 56 | } |
||||||
| 57 | } |
||||||
| 58 |