diff --git a/tests/Pecee/SimpleRouter/InputHandlerTest.php b/tests/Pecee/SimpleRouter/InputHandlerTest.php index 7fcb87b..99bd83e 100644 --- a/tests/Pecee/SimpleRouter/InputHandlerTest.php +++ b/tests/Pecee/SimpleRouter/InputHandlerTest.php @@ -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); }