public function testRequestAccessToken() { // Execute the API call EWSClient::requestAccessToken($this->httpClient, 'my_client_id', 'my_client_secret'); // Test the constructor fully new EWSClient($this->httpClient, 'my_client_id', 'my_client_secret'); // Get the request from the history $request = $this->history[1]['request']; // Assert that the request is made to the correct endpoint $this->assertRequestMethodSame('GET', $request); $this->assertRequestUriPathSame('oauth/v2/token', $request); // Assert that the query parameters are correct $this->assertRequestQueryParameterSame('client_id', 'my_client_id', $request); $this->assertRequestQueryParameterSame('client_secret', 'my_client_secret', $request); // Test getting and setting accessToken $this->ews = new EWSClient($this->httpClient, self::ACCESS_TOKEN); $access_token = 'token'; $this->ews->setAccessToken($access_token); $this->assertSame($access_token, $this->ews->getAccessToken()); // Test getting and setting the path $this->ews = new EWSClient($this->httpClient, self::ACCESS_TOKEN); $path = 'path'; $this->ews->setPath($path); $this->assertSame($path, $this->ews->getPath()); }
/** * Simple function to return an array of Participants based on search criteria. * * @param EWSClient $client * Client. * @param array $queries * Array of query arrays for building the query string. * @param string $class * Class name of the objects to create with the results. * @param string $path * Path to the API. * * @return array */ public static function searches($client, $queries, $class = '', $path = '') { $paths = []; foreach ($queries as $query) { $paths[] = $client->getPath() . $path . "?" . http_build_query($query); } $results_array = $client->requestJsons('GET', $paths); $objects = []; foreach ($results_array as $results) { foreach ($results['results'] as $result) { $objects[] = new $class($client, $result); } } return $objects; }