-, unit test, 200- ! , . getFileName(), getContentType(), isChunked() getChunkDetails(), transferChunk() .. , . , getContentType():
public function getContentType() {
if (isset($_SERVER["CONTENT_TYPE"]))
return $_SERVER["CONTENT_TYPE"];
if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
return $_SERVER["HTTP_CONTENT_TYPE"];
throw new FileTransferException('Unknown content type');
}
.
public function testUnknownContentType() {
$fixture = new FileTransfer();
unset($_SERVER["CONTENT_TYPE"]);
unset($_SERVER["HTTP_CONTENT_TYPE"]);
$fixture->getContentType();
}
public function testRegularContentType() {
$fixture = new FileTransfer();
$_SERVER["CONTENT_TYPE"] = 'regular';
unset($_SERVER["HTTP_CONTENT_TYPE"]);
self::assertEquals('regular', $fixture->getContentType());
}
public function testHttpContentType() {
$fixture = new FileTransfer();
unset($_SERVER["CONTENT_TYPE"]);
$_SERVER["HTTP_CONTENT_TYPE"] = 'http';
self::assertEquals('http', $fixture->getContentType());
}
public function testRegularContentTypeTakesPrecedence() {
$fixture = new FileTransfer();
$_SERVER["HTTP_CONTENT_TYPE"] = 'http';
$_SERVER["CONTENT_TYPE"] = 'regular';
self::assertEquals('regular', $fixture->getContentType());
}
, - . , -, php://input . "" " ": , , .
/ is_uploaded_file() , . isUploadedFile() openInputStream(). , . , is_uploaded_file() unit test. PHP, , , , (end-to-end).
- . , vfsStream.