public function testDeleteFile()
{
$this->setRequest(Request::create('/async/file/delete', 'POST', ['namespace' => 'files', 'filename' => self::FILE_NAME]));
// The file should still exist before deleting
$this->controller()->createFile($this->getRequest());
$this->assertTrue($this->getService('filesystem')->has(self::FILESYSTEM . '://' . self::FILE_NAME));
$response = $this->controller()->deleteFile($this->getRequest());
$this->assertInstanceOf(JsonResponse::class, $response);
$this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
// The file shouldn't exist anymore
$this->assertFalse($this->getService('filesystem')->has(self::FILESYSTEM . '://' . self::FILE_NAME));
// Attempting to delete the same file twice (or simply attempting to remove a file that doesn't exist) should
// return a 404 Not Found status code
$response = $this->controller()->deleteFile($this->getRequest());
$this->assertInstanceOf(JsonResponse::class, $response);
$this->assertEquals(Response::HTTP_NOT_FOUND, $response->getStatusCode());
}