/** * {@inheritdoc} */ public function update($path, $contents, Config $config) { $response = $this->client->updateFile($path, $contents); $responseContent = json_decode((string) $response->getBody()); $result = new FlysystemMetadata(FlysystemMetadata::TYPE_FILE, $path); $this->updateFlysystemMetadataFromResponseContent($result, $responseContent); return $result->toArray(); }
public function testUpdateFile() { $client = $this->getMockBuilder('\\GuzzleHttp\\Client')->getMock(); $accessToken = '123456789'; $content = 'updated file content'; $assertRequest = function ($request) use($accessToken, $content) { return $request instanceof Request && $request->getMethod() == 'PUT' && $request->getUri()->getHost() == 'api.onedrive.com' && $request->getUri()->getPath() == '/v1.0/drive/root:/updated%20file.txt:/content' && $request->getUri()->getQuery() == '@name.conflictBehavior=replace' && $request->getHeader('authorization') == ['bearer ' . $accessToken] && (string) $request->getBody() == $content; }; $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->updateFile('updated file.txt', $content); $this->assertEquals($response, $result); }