PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.20
Booking for Appointments and Events Calendar – Amelia v1.2.20
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / microsoft / microsoft-graph / tests / Http / GraphCollectionRequestTest.php
ameliabooking / vendor / microsoft / microsoft-graph / tests / Http Last commit date
GraphCollectionRequestTest.php 1 year ago GraphRequestTest.php 1 year ago GraphResponseTest.php 1 year ago HttpTest.php 1 year ago MockClientFactory.php 1 year ago StreamTest.php 1 year ago
GraphCollectionRequestTest.php
84 lines
1 <?php
2 use PHPUnit\Framework\TestCase;
3 use Microsoft\Graph\Http\GraphCollectionRequest;
4 use Microsoft\Graph\Model;
5
6 class GraphCollectionRequestTest extends TestCase
7 {
8 private $collectionRequest;
9 private $client;
10 private $reflectedRequestUrlHandler;
11
12 public function setUp(): void
13 {
14 $this->collectionRequest = new GraphCollectionRequest("GET", "/endpoint", "token", "url", "version");
15 $this->collectionRequest->setReturnType(Model\User::class);
16 $this->collectionRequest->setPageSize(2);
17
18 $body = json_encode(array('body' => 'content', '@odata.nextLink' => 'https://url/version/endpoint?skiptoken=link'));
19 $body2 = json_encode(array('body' => 'content'));
20 $mock = new AmeliaGuzzleHttp\Handler\MockHandler([
21 new AmeliaGuzzleHttp\Psr7\Response(200, ['foo' => 'bar'], $body),
22 new AmeliaGuzzleHttp\Psr7\Response(200, ['foo' => 'bar'], $body2),
23 new AmeliaGuzzleHttp\Psr7\Response(200, ['foo' => 'bar'], $body2),
24 ]);
25 $handler = AmeliaGuzzleHttp\HandlerStack::create($mock);
26 $this->client = new AmeliaGuzzleHttp\Client(['handler' => $handler]);
27
28 $this->reflectedRequestUrlHandler = new ReflectionMethod('Microsoft\Graph\Http\GraphRequest', '_getRequestUrl');
29 $this->reflectedRequestUrlHandler->setAccessible(true);
30 }
31
32 public function testHitEndOfCollection()
33 {
34 $this->expectError();
35
36 //First page
37 $this->collectionRequest->setPageCallInfo();
38 $response = $this->collectionRequest->execute($this->client);
39 $this->collectionRequest->processPageCallReturn($response);
40
41 //Last page
42 $this->collectionRequest->setPageCallInfo();
43 $response = $this->collectionRequest->execute($this->client);
44 $result1 = $this->collectionRequest->processPageCallReturn($response);
45
46 $this->assertTrue($this->collectionRequest->isEnd());
47
48 //Expect error
49 $this->collectionRequest->setPageCallInfo();
50 }
51
52 public function testProcessPageCallReturn()
53 {
54 $this->collectionRequest->setPageCallInfo();
55 $response = $this->collectionRequest->execute($this->client);
56 $result = $this->collectionRequest->processPageCallReturn($response);
57 $this->assertInstanceOf(Microsoft\Graph\Model\User::class, $result);
58 }
59
60 public function testEndpointManipulationWithoutNextLink()
61 {
62 //Page should be 1
63 $this->assertFalse($this->collectionRequest->isEnd());
64
65 $requestUrl = $this->reflectedRequestUrlHandler->invokeArgs($this->collectionRequest, array());
66
67 $this->assertEquals($requestUrl, 'version/endpoint');
68
69 $this->collectionRequest->setPageCallInfo();
70
71 $requestUrl = $this->reflectedRequestUrlHandler->invokeArgs($this->collectionRequest, array());
72 $this->assertEquals('version/endpoint?$top=2', $requestUrl);
73 }
74
75 public function testEndpointManipulationWhenNextLinkExists()
76 {
77 $this->collectionRequest->setPageCallInfo();
78 $response = $this->collectionRequest->execute($this->client);
79 $this->collectionRequest->processPageCallReturn($response);
80 $this->collectionRequest->setPageCallInfo();
81 $requestUrl = $this->reflectedRequestUrlHandler->invokeArgs($this->collectionRequest, array());
82 $this->assertEquals('version/endpoint?skiptoken=link', $requestUrl);
83 }
84 }