/** * @depends testPost * @expectedException \\Exception\Request * @expectedExceptionCode 404 */ public function testFailGet($location) { $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['HTTP_HOST'] = 'localhost'; $_SERVER['SERVER_NAME'] = 'localhost'; $_SERVER['SERVER_PORT'] = 80; $_SERVER['REQUEST_URI'] = str_replace('http://localhost', '', substr($location, 0, -1)); $server = new \Server(__DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'server', '/files/', array('prefix' => 'php-tus-test-')); $response = $server->process(false); }
$list_product_info = $this->get_package_from(self::DB_VARIABLE_NAME); //call method convert list product into json if (!is_null($list_product_info)) { $json_data = $this->jsonEncoder->list_import_product_to_json_data($list_product_info); } else { $json_data = array(); $json_data['error'] = 'No data'; $json_data = json_encode($json_data); } //response with the data encode with json, status 200 = OK $this->response($json_data, 200); } } //Server will work indepently. These code is to start the server $server = new Server(); $server->process(); // $data = array(); // $data['query'] = "Đ"; //TEST($server->get_list_of_import_product_info()); // $user_info = array('username' => 'ltkmai','password' =>'870814'); // $server->check_user_login(json_encode($user_info)); // $tmp = new SoldProduct(113); // $tmp->add_attribute("Sữa",100,new Unit("hộp",10000), "SUA1111", // new Trademark("RH11221", // new BasicInfo("Hồ Hữu Phát","*****@*****.**","0906332121","4 ABCD") // ,"Việt Nam","google.com.vn" // ) // ,"17/11/2015"); // $BasicInfo = new BasicInfo("Kim Nhật Thành","*****@*****.**","0923232121","4 ABCD"); // $receipt = new Receipt(1,1,new Employee("31313",$BasicInfo,10000,1,"1313131"), new Customer($BasicInfo)); // $receipt->add($tmp);
ini_set('display_errors', 1); error_reporting(E_ALL); } if ($_SERVER['REQUEST_METHOD'] !== "POST") { header("HTTP/1.1 303 See other"); header("Location: http://sblam.com"); die("See http://sblam.com"); } set_time_limit(20); require_once "dbconn.php"; require_once "class/server.php"; try { $config = Server::getDefaultConfig(); $services = new SblamServices(sblambaseconnect($config)); $server = new Server($config, $services); $server->process(new ServerRequest($services->getDB())); } catch (ServerException $e) { if (!headers_sent()) { header("HTTP/1.1 " . $e->getCode() . " " . $e->getMessage()); header("Content-Type: text/plain;charset=UTF-8"); } die($e->getMessage()); } catch (Exception $e) { if (!headers_sent()) { header("HTTP/1.1 500 err"); header("Content-Type: text/plain;charset=UTF-8"); } if (ini_get('display_errors')) { echo $e; } else { echo "Error";