public function testCanHandleServeIconRequest()
{
$file = new \ElggFile();
$file->owner_guid = 1;
$file->setFilename('600x300.jpg');
$path_key = \Elgg\Application::GET_PATH_KEY;
$this->request = \Elgg\Http\Request::create("?{$path_key}=serve-icon/{$this->entity->guid}/small");
$service = $this->createService();
$service->setCurrentTime();
$service->saveIconFromElggFile($this->entity, $file);
$response = $service->handleServeIconRequest(false);
$icon = $service->getIcon($this->entity, 'small');
$this->assertInstanceOf(\Symfony\Component\HttpFoundation\BinaryFileResponse::class, $response);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('image/jpeg', $response->headers->get('Content-Type'));
$filesize = filesize($icon->getFilenameOnFilestore());
$this->assertEquals($filesize, $response->headers->get('Content-Length'));
$this->assertContains('inline', $response->headers->get('Content-Disposition'));
$this->assertEquals('"' . $icon->getModifiedTime() . '"', $response->headers->get('Etag'));
$this->assertEquals($service->getCurrentTime('+1 day'), $response->getExpires());
$this->assertEquals('max-age=86400, private', $response->headers->get('cache-control'));
// now try conditional request
$this->request->headers->set('if-none-match', '"' . $icon->getModifiedTime() . '"');
$response = $service->handleServeIconRequest(false);
$this->assertEquals(304, $response->getStatusCode());
$this->assertEquals($service->getCurrentTime('+1 day'), $response->getExpires());
$this->assertEquals('max-age=86400, private', $response->headers->get('cache-control'));
}