-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16520 from sinbadxiii/issue-16519
fixed skipping application/x-www-form-urlencoded in getPut()
- Loading branch information
Showing
2 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -189,4 +189,49 @@ public function httpRequestGetPutMultipartFormData(UnitTester $I) | |
|
||
$_SERVER = $store; | ||
} | ||
|
||
/** | ||
* Tests Phalcon\Http\Request :: getPut() - x-www-form-urlencoded | ||
* | ||
* @issue @16519 | ||
* @author Phalcon Team <[email protected]> | ||
* @since 2024-01-29 | ||
*/ | ||
public function httpRequestGetPutApplicationtXWwwFormUrlencoded(UnitTester $I) | ||
{ | ||
$I->wantToTest('Http\Request - getPut() - x-www-form-urlencoded'); | ||
|
||
stream_wrapper_unregister('php'); | ||
stream_wrapper_register('php', PhpStream::class); | ||
|
||
file_put_contents('php://input', 'fruit=orange&quantity=4'); | ||
|
||
$store = $_SERVER ?? []; | ||
$time = $_SERVER['REQUEST_TIME_FLOAT']; | ||
$_SERVER = [ | ||
'REQUEST_TIME_FLOAT' => $time, | ||
'REQUEST_METHOD' => 'PUT', | ||
'CONTENT_TYPE' => "application/x-www-form-urlencoded", | ||
]; | ||
|
||
$request = new Request(); | ||
|
||
$expected = [ | ||
'fruit' => 'orange', | ||
'quantity' => '4', | ||
]; | ||
|
||
$actual = file_get_contents('php://input'); | ||
|
||
$I->assertSame("fruit=orange&quantity=4", $actual); | ||
|
||
$I->assertSame( | ||
$expected, | ||
$request->getPut() | ||
); | ||
|
||
stream_wrapper_restore('php'); | ||
|
||
$_SERVER = $store; | ||
} | ||
} |