init
This commit is contained in:
8
vendor/codeception/base/tests/data/rest/hhvm-server.ini
vendored
Normal file
8
vendor/codeception/base/tests/data/rest/hhvm-server.ini
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
hhvm.server.port = 8010
|
||||
hhvm.server.type = proxygen
|
||||
hhvm.server.default_document = index.php
|
||||
hhvm.server.error_document404 = index.php
|
||||
hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc
|
||||
hhvm.log.use_log_file = false
|
||||
hhvm.hack.lang.auto_typecheck=0
|
||||
hhvm.hack.lang.look_for_typechecker=0
|
||||
65
vendor/codeception/base/tests/data/rest/index.php
vendored
Normal file
65
vendor/codeception/base/tests/data/rest/index.php
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
include_once 'server.php';
|
||||
|
||||
$GLOBALS['RESTmap'] = [];
|
||||
|
||||
$GLOBALS['RESTmap']['GET'] = [
|
||||
'user' => function() {
|
||||
return [
|
||||
'name' => 'davert',
|
||||
'email' => 'davert@mail.ua',
|
||||
'aliases' => [
|
||||
'DavertMik',
|
||||
'davert.ua'
|
||||
],
|
||||
'address' => [
|
||||
'city' => 'Kyiv',
|
||||
'country' => 'Ukraine',
|
||||
]];
|
||||
},
|
||||
'zeroes' => function() {
|
||||
return [
|
||||
'responseCode' => 0,
|
||||
'message' => 'OK',
|
||||
'data' => [
|
||||
9,
|
||||
0,
|
||||
0
|
||||
],
|
||||
];
|
||||
},
|
||||
'http-host' => function() {
|
||||
return 'host: "' . $_SERVER['HTTP_HOST'] . '"';
|
||||
}
|
||||
|
||||
];
|
||||
|
||||
$GLOBALS['RESTmap']['POST'] = [
|
||||
'user' => function() {
|
||||
$name = $_POST['name'];
|
||||
return ['name' => $name];
|
||||
},
|
||||
'file-upload' => function() {
|
||||
return [
|
||||
'uploaded' => isset($_FILES['file']['tmp_name']) && file_exists($_FILES['file']['tmp_name']),
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
$GLOBALS['RESTmap']['PUT'] = [
|
||||
'user' => function() {
|
||||
$name = $_REQUEST['name'];
|
||||
$user = ['name' => 'davert', 'email' => 'davert@mail.ua'];
|
||||
$user['name'] = $name;
|
||||
return $user;
|
||||
}
|
||||
];
|
||||
|
||||
$GLOBALS['RESTmap']['DELETE'] = [
|
||||
'user' => function() {
|
||||
header('error', false, 404);
|
||||
}
|
||||
];
|
||||
|
||||
RESTServer();
|
||||
30
vendor/codeception/base/tests/data/rest/server.php
vendored
Normal file
30
vendor/codeception/base/tests/data/rest/server.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
function RESTServer()
|
||||
{
|
||||
// find the function/method to call
|
||||
$callback = NULL;
|
||||
if (preg_match('/rest\/([^\/]+)/i', $_SERVER['REQUEST_URI'], $m)) {
|
||||
if (isset($GLOBALS['RESTmap'][$_SERVER['REQUEST_METHOD']][$m[1]])) {
|
||||
$callback = $GLOBALS['RESTmap'][$_SERVER['REQUEST_METHOD']][$m[1]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($callback) {
|
||||
|
||||
// get the request data
|
||||
$data = NULL;
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
|
||||
$data = $_GET;
|
||||
} else if ($tmp = file_get_contents('php://input')) {
|
||||
$data = json_decode($tmp);
|
||||
}
|
||||
|
||||
$response = call_user_func($callback, $data);
|
||||
if (is_scalar($response)) {
|
||||
print $response;
|
||||
return;
|
||||
}
|
||||
print json_encode($response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user