/** * {@inheritdoc} */ public function getMetadata($path) { $response = $this->client->getMetadata($path); $responseContent = json_decode((string) $response->getBody()); $flysystemMetadata = new FlysystemMetadata(FlysystemMetadata::TYPE_FILE, $path); $this->updateFlysystemMetadataFromResponseContent($flysystemMetadata, $responseContent); return $flysystemMetadata->toArray(); }
public function testGetMetadata() { $client = $this->getMockBuilder('\\GuzzleHttp\\Client')->getMock(); $accessToken = '123456789'; $assertRequest = function ($request) use($accessToken) { return $request instanceof Request && $request->getMethod() == 'GET' && $request->getUri()->getHost() == 'api.onedrive.com' && $request->getUri()->getPath() == '/v1.0/drive/root:/some%20pdf%20document.pdf' && $request->getHeader('authorization') == ['bearer ' . $accessToken] && (string) $request->getBody() == ''; }; $response = new Response(200, [], 'test response'); $client->expects($this->once())->method('send')->with($this->callback($assertRequest))->willReturn($response); $oneDriveClient = new OneDriveClient($accessToken, $client); $result = $oneDriveClient->getMetadata('some pdf document.pdf'); $this->assertEquals($response, $result); }