public function test_assert_array() { assert_array(array()); assert_fails(function () { assert_array(1); }); assert_fails(function () { assert_array(new stdClass()); }); }
<?php describe("JSON Response", function () { before(function () { $response = new JSONResponse(array("id" => "100", array("location" => array("city" => "Pico Rivera", "state" => "CA")))); return $response; }); it("generates json response", function ($response) { $data = '{"id":"100","0":{"location":{"city":"Pico Rivera","state":"CA"}}}'; assert_equal($data, $response->to_json()); }); it("retrieves values", function ($response) { $json = json_decode($response->to_json(), true); assert_equal($json["id"], "100"); assert_array($json[0]); assert_array($json[0]["location"]); assert_equal($json[0]["location"]["city"], "Pico Rivera"); assert_equal($json[0]["location"]["state"], "CA"); }); });
}); it("returns an array with controller and action and ids", function () { Router::prepare(function ($r) { $r->match("/:controller/:action")->to(array("controller" => "application", "action" => "method")); }); $d = Dispatcher::getInstance(); $params = $d->find_route("/application/method"); assert_equal($params["controller"], "application"); assert_equal($params["action"], "method"); }); }); describe("Dispatcher -> params", function () { it("returns an array", function () { $d = Dispatcher::getInstance(); $params = $d->params(); assert_array($params); }); it("array has keys from \$_GET and \$_POST", function () { $_GET['name'] = "Dwight"; $_POST['id'] = "200"; $d = Dispatcher::getInstance(); $params = $d->params(); assert_array_has_keys($params, array("id", "name")); $_GET = array(); $_POST = array(); }); it("array has values from \$_GET and \$_POST", function () { $_GET['name'] = "Dwight"; $_POST['id'] = "200"; $d = Dispatcher::getInstance(); $params = $d->params();
function php($atts, $thing) { global $is_article_body, $thisarticle, $prefs; if (assert_array($prefs) === FALSE) { return ''; } ob_start(); if (empty($is_article_body)) { if (!empty($prefs['allow_page_php_scripting'])) { eval($thing); } else { trigger_error(gTxt('php_code_disabled_page')); } } else { if (!empty($prefs['allow_article_php_scripting'])) { if (has_privs('article.php', $thisarticle['authorid'])) { eval($thing); } else { trigger_error(gTxt('php_code_forbidden_user')); } } else { trigger_error(gTxt('php_code_disabled_article')); } } return ob_get_clean(); }
function evalString($html) { global $prefs; if (strpos($html, chr(60) . '?php') !== false) { trigger_error(gTxt('raw_php_deprecated'), E_USER_WARNING); if (assert_array($prefs) === FALSE) { return $html; } if (!empty($prefs['allow_raw_php_scripting'])) { $html = eval(' ?' . chr(62) . $html . chr(60) . '?php '); } else { trigger_error(gTxt('raw_php_disabled'), E_USER_WARNING); } } return $html; }