AbstractAccessTokenCest::generateToken()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 13
nc 1
nop 2
dl 0
loc 17
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\roa\test;
4
5
use Codeception\{Example, Util\HttpCode};
6
7
abstract class AbstractAccessTokenCest
8
{
9
    /**
10
     * Generates and stores an auth token.
11
     *
12
     * @param Tester $I
13
     * @param Example $example must contain keys:
14
     * - client: string http client.
15
     * - clientPass: string http password.
16
     * - user: string system user.
17
     * - userPass: string user password.
18
     * - tokenName: token name used to store the auth token.
19
     */
20
    protected function generateToken(Tester $I, Example $example)
21
    {
22
        $I->amHttpAuthenticated($example['client'], $example['clientPass']);
0 ignored issues
show
Bug introduced by
The method amHttpAuthenticated() does not exist on roaresearch\yii2\roa\test\Tester. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
        $I->/** @scrutinizer ignore-call */ 
23
            amHttpAuthenticated($example['client'], $example['clientPass']);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
        $I->sendPOST($this->getRoute(), [
0 ignored issues
show
Bug introduced by
The method sendPOST() does not exist on roaresearch\yii2\roa\test\Tester. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        $I->/** @scrutinizer ignore-call */ 
24
            sendPOST($this->getRoute(), [

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
24
            'grant_type' => 'password',
25
            'username' => $example['user'],
26
            'password' => $example['userPass'],
27
        ]);
28
        $I->seeResponseCodeIs(HttpCode::OK);
0 ignored issues
show
Bug introduced by
The method seeResponseCodeIs() does not exist on roaresearch\yii2\roa\test\Tester. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
        $I->/** @scrutinizer ignore-call */ 
29
            seeResponseCodeIs(HttpCode::OK);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        $I->seeResponseIsJson();
0 ignored issues
show
Bug introduced by
The method seeResponseIsJson() does not exist on roaresearch\yii2\roa\test\Tester. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $I->/** @scrutinizer ignore-call */ 
30
            seeResponseIsJson();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
        $I->seeResponseMatchesJsonType([
0 ignored issues
show
Bug introduced by
The method seeResponseMatchesJsonType() does not exist on roaresearch\yii2\roa\test\Tester. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
        $I->/** @scrutinizer ignore-call */ 
31
            seeResponseMatchesJsonType([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
31
            'access_token' => 'string:regex(/[0-9a-f]{40}/)',
32
            'refresh_token' => 'string:regex(/[0-9a-f]{40}/)',
33
        ]);
34
        $I->storeToken(
35
            $example['tokenName'],
36
            $I->grabDataFromResponseByJsonPath('access_token')[0]
0 ignored issues
show
Bug introduced by
The method grabDataFromResponseByJsonPath() does not exist on roaresearch\yii2\roa\test\Tester. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
            $I->/** @scrutinizer ignore-call */ 
37
                grabDataFromResponseByJsonPath('access_token')[0]

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
        );
38
    }
39
40
    /**
41
     * @return string url route which generates the token.
42
     */
43
    protected function getRoute()
44
    {
45
        return 'oauth2/token';
46
    }
47
}
48