Core
1 year ago
Exception
6 years ago
Functional
1 year ago
Http
1 year ago
Model
1 year ago
GetPhpInfo.php
1 year ago
GraphTest.php
1 year ago
GraphTest.php
75 lines
| 1 | <?php |
| 2 | use PHPUnit\Framework\TestCase; |
| 3 | use Microsoft\Graph\Core\GraphConstants; |
| 4 | use Microsoft\Graph\Graph; |
| 5 | use Microsoft\Graph\Http\GraphRequest; |
| 6 | |
| 7 | class GraphTest extends TestCase |
| 8 | { |
| 9 | public function testGraphConstructor() |
| 10 | { |
| 11 | $graph = new Graph(); |
| 12 | $this->assertNotNull($graph); |
| 13 | } |
| 14 | |
| 15 | public function testInitializeEmptyGraph() |
| 16 | { |
| 17 | $this->expectException(Microsoft\Graph\Exception\GraphException::class); |
| 18 | $graph = new Graph(); |
| 19 | $request = $graph->createRequest("GET", "/me"); |
| 20 | } |
| 21 | |
| 22 | public function testInitializeGraphWithToken() |
| 23 | { |
| 24 | $graph = new Graph(); |
| 25 | $graph->setAccessToken('abc'); |
| 26 | $request = $graph->createRequest("GET", "/me"); |
| 27 | |
| 28 | $this->assertInstanceOf(GraphRequest::class, $request); |
| 29 | } |
| 30 | |
| 31 | public function testCreateCollectionRequest() |
| 32 | { |
| 33 | $graph = new Graph(); |
| 34 | $graph->setAccessToken('abc'); |
| 35 | $request = $graph->createCollectionRequest("GET", "/me"); |
| 36 | |
| 37 | $this->assertInstanceOf(GraphRequest::class, $request); |
| 38 | } |
| 39 | |
| 40 | public function testRequestWithCustomEndpoint() |
| 41 | { |
| 42 | $graph = new Graph(); |
| 43 | $graph->setAccessToken('abc'); |
| 44 | $graph->setBaseUrl('url2'); |
| 45 | |
| 46 | $request = $graph->createRequest("GET", "/me"); |
| 47 | $this->assertEquals('url2', $request->getBaseUrl()); |
| 48 | } |
| 49 | |
| 50 | public function testBetaRequest() |
| 51 | { |
| 52 | $graph = new Graph(); |
| 53 | $graph->setAccessToken('abc') |
| 54 | ->setApiVersion('beta'); |
| 55 | $request = $graph->createRequest("GET", "/me"); |
| 56 | |
| 57 | $this->assertEquals('beta', $request->getApiVersion()); |
| 58 | } |
| 59 | |
| 60 | public function testMultipleGraphObjects() |
| 61 | { |
| 62 | $graph = new Graph(); |
| 63 | $graph2 = new Graph(); |
| 64 | |
| 65 | $graph->setAccessToken('abc'); |
| 66 | $graph2->setAccessToken('abc'); |
| 67 | $graph2->setApiVersion('beta'); |
| 68 | |
| 69 | $request = $graph->createRequest("GET", "/me"); |
| 70 | $request2 = $graph2->createRequest("GET", "/me"); |
| 71 | |
| 72 | $this->assertEquals(GraphConstants::API_VERSION, $request->getApiVersion()); |
| 73 | $this->assertEquals('beta', $request2->getApiVersion()); |
| 74 | } |
| 75 | } |