mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-16 18:50:11 +03:00
[BUGFIX] Fixed InputHandler::find and InputHandler::value failing when using array methods.
This commit is contained in:
@@ -231,6 +231,10 @@ class InputHandler
|
||||
{
|
||||
$element = null;
|
||||
|
||||
if(count($methods) > 0) {
|
||||
$methods = is_array(...$methods) ? array_values(...$methods) : $methods;
|
||||
}
|
||||
|
||||
if (count($methods) === 0 || in_array(Request::REQUEST_TYPE_GET, $methods, true) === true) {
|
||||
$element = $this->get($index);
|
||||
}
|
||||
|
||||
@@ -122,7 +122,20 @@ class InputHandlerTest extends \PHPUnit\Framework\TestCase
|
||||
$_GET = [];
|
||||
}
|
||||
|
||||
public function testFindInput() {
|
||||
|
||||
global $_POST;
|
||||
$_POST['hello'] = 'motto';
|
||||
|
||||
$router = TestRouter::router();
|
||||
$router->reset();
|
||||
$router->getRequest()->setMethod('post');
|
||||
$inputHandler = TestRouter::request()->getInputHandler();
|
||||
|
||||
$value = $inputHandler->value('hello', null, \Pecee\Http\Request::$requestTypesPost);
|
||||
|
||||
$this->assertEquals($_POST['hello'], $value);
|
||||
}
|
||||
|
||||
public function testFile()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user