mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Added file content test for all platforms
This commit is contained in:
@@ -114,12 +114,13 @@ class InputHandlerTest extends \PHPUnit\Framework\TestCase
|
|||||||
public function testFile()
|
public function testFile()
|
||||||
{
|
{
|
||||||
global $_FILES;
|
global $_FILES;
|
||||||
|
$temp_dir = sys_get_temp_dir();
|
||||||
|
|
||||||
$_FILES = array(
|
$_FILES = array(
|
||||||
'test' => array(
|
'test' => array(
|
||||||
'name' => 'test.txt',
|
'name' => 'test.txt',
|
||||||
'type' => 'text/plain',
|
'type' => 'text/plain',
|
||||||
'tmp_name' => '/tmp/phpYfWUiw',
|
'tmp_name' => $temp_dir . '/phpYfWUiw',
|
||||||
'error' => 0,
|
'error' => 0,
|
||||||
'size' => 4
|
'size' => 4
|
||||||
)
|
)
|
||||||
@@ -134,19 +135,16 @@ class InputHandlerTest extends \PHPUnit\Framework\TestCase
|
|||||||
$this->assertInstanceOf(\Pecee\Http\Input\InputFile::class, $file);
|
$this->assertInstanceOf(\Pecee\Http\Input\InputFile::class, $file);
|
||||||
$this->assertEquals('test.txt', $file->getFilename());
|
$this->assertEquals('test.txt', $file->getFilename());
|
||||||
$this->assertEquals('text/plain', $file->getType());
|
$this->assertEquals('text/plain', $file->getType());
|
||||||
$this->assertEquals('/tmp/phpYfWUiw', $file->getTmpName());
|
$this->assertEquals($temp_dir . '/phpYfWUiw', $file->getTmpName());
|
||||||
$this->assertEquals(0, $file->getError());
|
$this->assertEquals(0, $file->getError());
|
||||||
$this->assertEquals(4, $file->getSize());
|
$this->assertEquals(4, $file->getSize());
|
||||||
$this->assertEquals('txt', $file->getExtension());
|
$this->assertEquals('txt', $file->getExtension());
|
||||||
|
|
||||||
|
file_put_contents($temp_dir . '/phpYfWUiw', 'test');
|
||||||
|
$this->assertEquals('test', $file->getContents());
|
||||||
|
|
||||||
if(file_exists('/tmp')){
|
//cleanup
|
||||||
file_put_contents('/tmp/phpYfWUiw', 'test');
|
unlink($temp_dir . '/phpYfWUiw');
|
||||||
$this->assertEquals('test', $file->getContents());
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: implement test-file
|
|
||||||
$this->assertEquals(true, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFiles()
|
public function testFiles()
|
||||||
|
|||||||
Reference in New Issue
Block a user