forked from microsoftgraph/msgraph-sdk-php
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGraphTest.php
More file actions
76 lines (62 loc) · 2.19 KB
/
Copy pathGraphTest.php
File metadata and controls
76 lines (62 loc) · 2.19 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
use PHPUnit\Framework\TestCase;
use Microsoft\Graph\Core\GraphConstants;
use Microsoft\Graph\Graph;
use Microsoft\Graph\Http\GraphRequest;
class GraphTest extends TestCase
{
public function testGraphConstructor()
{
$graph = new Graph();
$this->assertNotNull($graph);
}
public function testInitializeEmptyGraph()
{
$this->expectException(Microsoft\Graph\Exception\GraphException::class);
$graph = new Graph();
$request = $graph->createRequest("GET", "/me");
}
public function testInitializeGraphWithToken()
{
$graph = new Graph();
$graph->setAccessToken('abc');
$request = $graph->createRequest("GET", "/me");
$this->assertInstanceOf(GraphRequest::class, $request);
}
public function testCreateCollectionRequest()
{
$graph = new Graph();
$graph->setAccessToken('abc');
$request = $graph->createCollectionRequest("GET", "/me");
$this->assertInstanceOf(GraphRequest::class, $request);
}
public function testRequestWithCustomEndpoint()
{
$graph = new Graph();
$graph->setAccessToken('abc');
$graph->setBaseUrl('url2');
$request = $graph->createRequest("GET", "/me");
$requestUrl = $this->readAttribute($request, 'baseUrl');
$this->assertEquals('url2', $requestUrl);
}
public function testBetaRequest()
{
$graph = new Graph();
$graph->setAccessToken('abc')
->setApiVersion('/beta');
$request = $graph->createRequest("GET", "/me");
$this->assertEquals('/beta', $this->readAttribute($request, 'apiVersion'));
}
public function testMultipleGraphObjects()
{
$graph = new Graph();
$graph2 = new Graph();
$graph->setAccessToken('abc');
$graph2->setAccessToken('abc');
$graph2->setApiVersion('/beta');
$request = $graph->createRequest("GET", "/me");
$request2 = $graph2->createRequest("GET", "/me");
$this->assertEquals(GraphConstants::API_VERSION, $this->readAttribute($request, 'apiVersion'));
$this->assertEquals('/beta', $this->readAttribute($request2, 'apiVersion'));
}
}