のsysinfo:symfonyのwebフォルダにある静的ファイルをphpunitでテストするには?
- のPHPUnit 5.7.4
- PHP 7.0.13
- symfonyの3.2.1
私は "ダウンロード" ページ上のリンクをたどると、検証しようとしていますファイルはダウンロード可能ですが、私が$client->click($crawlerDownload->link());
のリンクに従うと404
となります。 symfony $client
がwebdirectoryの静的ファイルにアクセスすることはできませんか?どのように私はこれをテストできますか?
faviconテストは、テストケースの簡略化されたバージョンです。あなたは、テストはアプリケーションをブートストラップしていることはできません
public function testPressDownload()
{
$client = static::createClient();
$client->followRedirects(false);
//create fixture file
$kernelDir = $client->getKernel()->getRootDir();
$file = "${kernelDir}/../web/download/example.zip";
file_put_contents($file, "dummy content");
$crawler = $client->request('GET', '/files');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); //ok
$crawlerDownload = $crawler
->filter('a[title="example.zip"]')
;
$this->assertEquals(1, $crawlerDownload->count()); //ok
$client->click($crawlerDownload->link());
$this->assertEquals(200, $client->getResponse()->getStatusCode()); //fails 404
}
public function testFavicon()
{
$crawler = $client->request('GET', '/favicon.ico');
$this->assertEquals(200, $client->getResponse()->getStatusCode()); //fails 404
}
'$ crawler = $ client-> request( 'GET'、 'favicon.ico');はスラッシュを付けませんでしたか? –
yesもスラッシュ '/'なしで試しました。同じ結果 - > '404' – c33s