mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-16 02:30:09 +03:00
testFiles and test file content on server
This commit is contained in:
@@ -113,6 +113,38 @@ class InputHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
|
||||
public function testFile()
|
||||
{
|
||||
global $_FILES;
|
||||
|
||||
$_FILES = array(
|
||||
'test' => array(
|
||||
'name' => 'test.txt',
|
||||
'type' => 'text/plain',
|
||||
'tmp_name' => '/tmp/phpYfWUiw',
|
||||
'error' => 0,
|
||||
'size' => 4
|
||||
)
|
||||
);
|
||||
|
||||
$router = TestRouter::router();
|
||||
$router->reset();
|
||||
$router->getRequest()->setMethod('post');
|
||||
|
||||
$handler = TestRouter::request()->getInputHandler();
|
||||
$file = $handler->file('test');
|
||||
$this->assertInstanceOf(\Pecee\Http\Input\InputFile::class, $file);
|
||||
$this->assertEquals('test.txt', $file->getFilename());
|
||||
$this->assertEquals('text/plain', $file->getType());
|
||||
$this->assertEquals('/tmp/phpYfWUiw', $file->getTmpName());
|
||||
$this->assertEquals(0, $file->getError());
|
||||
$this->assertEquals(4, $file->getSize());
|
||||
$this->assertEquals('txt', $file->getExtension());
|
||||
|
||||
|
||||
if(file_exists('/tmp')){
|
||||
file_put_contents('/tmp/phpYfWUiw', 'test');
|
||||
$this->assertEquals('test', $file->getContents());
|
||||
}
|
||||
|
||||
// TODO: implement test-file
|
||||
$this->assertEquals(true, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user