sysinfo:
- PHPUnit 5.7.4
- PHP 7.0.13
- Symfony 3.2.1
i am trying to follow a link on a "download" page and verify the file is downloadable but when i follow the link $client->click($crawlerDownload->link());
i get a 404
. is it not possible for the symfony $client
to access a static file in the webdirectory? how can i test this?
the favicon test is the simplified version of the testcase.
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
}