/** * @param string $fileUrl * @param string $downloadFormHtml * @param string $downloadInfoJson * @return \Ndthuan\FshareLib\Api\DTO\DownloadableUrl */ private function performDownloadInfoFetchingProcess($fileUrl, $downloadFormHtml, $downloadInfoJson) { $pageRequest = new Request('GET', $fileUrl); $downloadInfoRequest = new Request('POST', 'https://www.fshare.vn/download/get'); $downloadInfoOptions = ['form_params' => ['fs_csrf' => 'xxx', 'DownloadForm[pwd]' => '', 'DownloadForm[linkcode]' => 'yyy', 'ajax' => 'download-form']]; $this->clientMock->expects(static::exactly(2))->method('send')->withConsecutive([$pageRequest, ['allow_redirects' => false]], [$downloadInfoRequest, $downloadInfoOptions])->willReturnOnConsecutiveCalls(new Response(200, [], $downloadFormHtml), new Response(200, [], $downloadInfoJson)); $this->requestDecoratorMock->expects(static::exactly(2))->method('decorate')->willReturnArgument(0); $this->authenticatorMock->expects(static::once())->method('authenticate'); return $this->testObject->fetchDownloadableUrl($fileUrl); }
public function testFetchFileInfo() { $file = $this->fileFetcher->fetchFileInfo(FSHARE_TEST_FILE_URL); static::assertEquals(FSHARE_TEST_FILE_URL, $file->getUrl()); static::assertEquals(FSHARE_TEST_FILE_EXPECTED_NAME, $file->getName()); }