diff --git a/tests/Pecee/SimpleRouter/InputHandlerTest.php b/tests/Pecee/SimpleRouter/InputHandlerTest.php index 163ab67..fc3baf1 100644 --- a/tests/Pecee/SimpleRouter/InputHandlerTest.php +++ b/tests/Pecee/SimpleRouter/InputHandlerTest.php @@ -1,5 +1,7 @@ 'test.txt', + 'type' => 'text/plain', + 'tmp_name' => $temp_dir . '/phpYfWUiw', + 'error' => 0, + 'size' => 4 + ); + $test_file_content = 'test_content'; + $_FILES = array( - 'test' => array( - 'name' => 'test.txt', - 'type' => 'text/plain', - 'tmp_name' => $temp_dir . '/phpYfWUiw', - 'error' => 0, - 'size' => 4 - ) + $test_file_input_name => $test_file ); $router = TestRouter::router(); @@ -131,20 +137,20 @@ class InputHandlerTest extends \PHPUnit\Framework\TestCase $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($temp_dir . '/phpYfWUiw', $file->getTmpName()); - $this->assertEquals(0, $file->getError()); - $this->assertEquals(4, $file->getSize()); - $this->assertEquals('txt', $file->getExtension()); + $file = $handler->file($test_file_input_name); + $this->assertInstanceOf(InputFile::class, $file); + $this->assertEquals($test_file['name'], $file->getFilename()); + $this->assertEquals($test_file['type'], $file->getType()); + $this->assertEquals($test_file['tmp_name'], $file->getTmpName()); + $this->assertEquals($test_file['error'], $file->getError()); + $this->assertEquals($test_file['size'], $file->getSize()); + $this->assertEquals(pathinfo($test_file['name'], PATHINFO_EXTENSION), $file->getExtension()); - file_put_contents($temp_dir . '/phpYfWUiw', 'test'); - $this->assertEquals('test', $file->getContents()); + file_put_contents($test_file['tmp_name'], $test_file_content); + $this->assertEquals($test_file_content, $file->getContents()); //cleanup - unlink($temp_dir . '/phpYfWUiw'); + unlink($test_file['tmp_name']); } public function testFiles()