Last active
February 8, 2016 22:53
-
-
Save Raistlfiren/911f4f924956f4fc2bce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$app = new App(); | |
$app->post('/', function(ServerRequestInterface $request, ResponseInterface $response) { | |
//ERROR on functional test - Cannot modify header information - headers already sent by | |
$filename = filter_var($filename, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); | |
header('Content-Type: application/octet-stream'); | |
header('Content-Transfer-Encoding: binary'); | |
header("Content-Disposition: attachment; filename=\"$filename\""); | |
}); | |
//Functional test | |
$_FILES = 'csvFileToProcess' => [ | |
'tmp_name' => __DIR__ . DIRECTORY_SEPARATOR . '../Resources/GenericExport.csv', | |
'name' => 'GenericExport.csv', | |
'type' => 'text/csv', | |
'error' => 0, | |
'size' => 4256, | |
]; | |
$env = Environment::mock([ | |
'REQUEST_URI' => '/', | |
'REQUEST_METHOD' => 'POST' | |
]); | |
$uri = Uri::createFromEnvironment($env); | |
$headers = Headers::createFromEnvironment($env); | |
$files = UploadedFile::createFromEnvironment(Environment::mock()); | |
$cookies = []; | |
$serverParams = $env->all(); | |
$body = new RequestBody(); | |
$this->request = new Request('POST', $uri, $headers, $cookies, $serverParams, $body, $files); | |
$this->response = new Response(); | |
$response = $app($this->request, $this->response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment