Skip to content
Extraits de code Groupes Projets
Valider 8f8dcdfe rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

added tests for http post

parent f68a5411
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<?php
// used in integration tests to see if POST method works.
// for security reasons we allow max 3 post vars, each key and value is only allowed to have max 6 hex characters
function accept($key)
{
if (ctype_xdigit($key) && strlen($key) <= 6) {
return $key;
}
}
if (count($_POST) > 4) {
exit;
}
$values = array();
foreach ($_POST as $key => $value) {
if (accept($key) && accept($value)) {
$values[$key] = $value;
}
}
if (!empty($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
$values['method'] = 'post';
}
echo json_encode($values);
exit;
......@@ -167,6 +167,58 @@ class HttpTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(401, $result['status']);
}
/**
* @dataProvider getMethodsToTest
*/
public function testHttpPost_ViaString($method)
{
$result = Http::sendHttpRequestBy(
$method,
Fixture::getRootUrl() . 'tests/PHPUnit/Integration/Http/Post.php',
30,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSslCertificate = false,
$byteRange = false,
$getExtendedInfo = false,
$httpMethod = 'POST',
$httpUsername = '',
$httpPassword = '',
'abc12=43&abfec=abcdef'
);
$this->assertEquals('{"abc12":"43","abfec":"abcdef","method":"post"}', $result);
}
/**
* @dataProvider getMethodsToTest
*/
public function testHttpPost_ViaArray($method)
{
$result = Http::sendHttpRequestBy(
$method,
Fixture::getRootUrl() . 'tests/PHPUnit/Integration/Http/Post.php',
30,
$userAgent = null,
$destinationPath = null,
$file = null,
$followDepth = 0,
$acceptLanguage = false,
$acceptInvalidSslCertificate = false,
$byteRange = false,
$getExtendedInfo = false,
$httpMethod = 'POST',
$httpUsername = '',
$httpPassword = '',
array('adf2' => '44', 'afc23' => 'ab12')
);
$this->assertEquals('{"adf2":"44","afc23":"ab12","method":"post"}', $result);
}
/**
* @dataProvider getMethodsToTest
*/
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter