testFiles and test file content on server

This commit is contained in:
DeveloperMarius
2021-03-24 13:11:07 +01:00
parent 22d531178a
commit 5624c4b2bb

View File

@@ -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);
}