/** * @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); }
/** * @expectedException \Ndthuan\FshareLib\HtmlClient\DownloadFormNotFoundException * @expectedExceptionMessage Download form not found */ public function testFetchDownloadableUrlIfFileUrlIsInvalidShouldThrowException() { $this->fileFetcher->fetchDownloadableUrl('http://www.fshare.vn/'); }