forked from microsoftgraph/msgraph-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphServiceClientTest.php
More file actions
43 lines (37 loc) · 2.04 KB
/
Copy pathGraphServiceClientTest.php
File metadata and controls
43 lines (37 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace Microsoft\Graph\Test;
use Microsoft\Graph\Core\NationalCloud;
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Kiota\Abstractions\Authentication\AnonymousAuthenticationProvider;
use Microsoft\Kiota\Authentication\Oauth\ClientCredentialContext;
use Microsoft\Kiota\Http\GuzzleRequestAdapter;
use PHPUnit\Framework\TestCase;
class GraphServiceClientTest extends TestCase
{
public function testsInit(): void
{
$client = GraphServiceClient::createWithRequestAdapter(new GuzzleRequestAdapter(new AnonymousAuthenticationProvider()));
$this->assertInstanceOf(GraphServiceClient::class, $client);
$testContext = new ClientCredentialContext('tenant', 'client', 'secret');
$client = new GraphServiceClient($testContext);
$this->assertInstanceOf(GraphServiceClient::class, $client);
$client = new GraphServiceClient($testContext, ['Users.Read']);
$this->assertInstanceOf(GraphServiceClient::class, $client);
}
public function testCorrectDefaultBaseUrlIsSetWhenRequestAdapterHasEmptyBaseUrl(): void
{
$requestAdapter = new GuzzleRequestAdapter(new AnonymousAuthenticationProvider());
$client = GraphServiceClient::createWithRequestAdapter($requestAdapter);
$this->assertEquals(NationalCloud::GLOBAL.'/v1.0', $client->getRequestAdapter()->getBaseUrl());
$requestAdapter = new GuzzleRequestAdapter(new AnonymousAuthenticationProvider());
$client = GraphServiceClient::createWithRequestAdapter($requestAdapter, NationalCloud::CHINA);
$this->assertEquals(NationalCloud::CHINA.'/v1.0', $client->getRequestAdapter()->getBaseUrl());
}
public function testCustomBaseUrlIsNotOverriden(): void
{
$requestAdapter = new GuzzleRequestAdapter(new AnonymousAuthenticationProvider());
$requestAdapter->setBaseUrl(NationalCloud::CHINA);
$client = GraphServiceClient::createWithRequestAdapter($requestAdapter, NationalCloud::US_DOD);
$this->assertEquals(NationalCloud::CHINA, $client->getRequestAdapter()->getBaseUrl());
}
}