Esempio n. 1
0
    exit;
}
if (isset($_GET["headers"])) {
    echo headers();
    exit;
}
if (isset($_GET["lang"])) {
    echo language();
    exit;
}
if (isset($_GET["deliver"])) {
    echo deliver();
    exit;
}
if (isset($_GET["attachments"])) {
    echo attachments();
    exit;
}
if (isset($_GET["digest"])) {
    echo digest();
    exit;
}
if (isset($_GET["msgheader"])) {
    echo msg_header();
    exit;
}
if (isset($_GET["msg_header"])) {
    msg_header_save();
    exit;
}
if (isset($_GET["msgfooter"])) {
Esempio n. 2
0
}
$_SESSION['foo'] = 'beep boop';
session('bar', 'boop beep');
assert(session('foo') === 'beep boop');
assert(session('bar') === 'boop beep');
assert(session('lol') === null);
# single file upload
$_FILES['photo'] = ['name' => 'photo.png', 'type' => 'image/png', 'size' => 5120, 'tmp_name' => '/tmp/tmpfile123', 'error' => UPLOAD_ERR_OK];
# array upload
$_FILES['thumbs'] = ['name' => ['thumb1.png', 'thumb2.png', 'thumb3.png'], 'type' => ['image/png', 'image/png', 'image/png'], 'size' => [5120, 5121, 5122], 'tmp_name' => ['/tmp/upload1', '/tmp/upload2', '/tmp/upload3'], 'error' => [UPLOAD_ERR_OK, UPLOAD_ERR_OK, UPLOAD_ERR_OK]];
# check single file upload
assert($_FILES['photo'] === attachments('photo'));
# check array upload
assert(attachments('thumbs')[0] === ['name' => 'thumb1.png', 'type' => 'image/png', 'size' => 5120, 'tmp_name' => '/tmp/upload1', 'error' => UPLOAD_ERR_OK]);
# check for invalids
assert(attachments('invalid') === null);
# load mock file directly
list($_, $data) = input(true, __DIR__ . '/fixtures/sample.json');
assert(trim($data) === json_encode(['name' => 'dispatch']));
# put mock file into temp file
list($_, $path) = input(false, __DIR__ . '/fixtures/sample.json');
assert(file_exists($path));
assert(file_get_contents($path) === $data);
# global container for routes
$routes =& $GLOBALS['noodlehaus\\dispatch']['routes'];
# 3-arg mappings
map('GET', '/route1', 'cb1');
assert(in_array(['/route1', 'cb1'], $routes['explicit']['GET']));
map(['GET', 'POST'], '/route2', 'cb2');
assert(in_array(['/route2', 'cb2'], $routes['explicit']['GET']));
assert(in_array(['/route2', 'cb2'], $routes['explicit']['POST']));