OAuth2ClientTest::testCreateAuthorizationUrl()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 9
c 3
b 1
f 0
dl 0
loc 16
rs 9.9666
ccs 8
cts 8
cp 1
cc 2
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * @project tiktok-marketing-api
4
 */
5
6
namespace Promopult\TikTokMarketingApi\Tests;
7
8
use Promopult\TikTokMarketingApi\OAuth2Client;
9
use PHPUnit\Framework\TestCase;
10
11
class OAuth2ClientTest extends TestCase
12
{
13 1
    public function testCreateAuthorizationUrl()
14
    {
15 1
        $expected = 'https://ads.tiktok.com/marketing_api/auth?app_id=appId&state=state&redirect_uri=redirectUri&scope=%5B1%2C2%5D';
16 1
17 1
        $actual = OAuth2Client::createAuthorizationUrl(
18
            'appId',
19 1
            'redirectUri',
20
            'state',
21 1
            [1, 2],
22 1
            'https://ads.tiktok.com'
23
        );
24 1
25
        $partsToTest = [PHP_URL_HOST, PHP_URL_PATH, PHP_URL_QUERY, PHP_URL_SCHEME];
26
27
        foreach ($partsToTest as $part) {
28
            $this->assertEquals(parse_url($expected, $part), parse_url($actual, $part));
29
        }
30
    }
31
}
32