public function shouldThrowExceptionOnInvalidEmail()
 {
     // given
     $this->createPlayer();
     // when
     $handler = new LudoDBRequestHandler();
     $json = $handler->handle(array('request' => 'PasswordLookup/save', 'data' => array('email' => '*****@*****.**')));
     $data = json_decode($json, true);
     // then
     $this->assertFalse($data['success'], $json);
 }
 /**
  * Start profiling.
  * @param array $data
  * @return array
  * @throws LudoDBException
  */
 public function profile($data = array())
 {
     $inDevelop = LudoDBRegistry::get('DEVELOP_MODE');
     if (!isset($inDevelop) || !$inDevelop) {
         throw new LudoDBException("Profiling can only be executed in develop mode. Use LudoDBRegistry::set('DEVELOP_MODE', true) to activate develop mode");
     }
     $request = implode("/", $this->arguments);
     $name = preg_replace("/[^0-9a-z]/si", "", $request);
     $this->start($name);
     $handler = new LudoDBRequestHandler();
     $result = json_decode($handler->handle(array('request' => $request, 'data' => $data)), true);
     if (!$result['success']) {
         throw new LudoDBException($result['message']);
     }
     $url = $this->end();
     return array("result" => $url, "request" => $request, "data" => $data);
 }
示例#3
0
 private function triggerJSONFor($className, $arguments = array())
 {
     $request = new LudoDBRequestHandler();
     $requestString = $className;
     if (!is_array($arguments)) {
         $arguments = array($arguments);
     }
     if (!empty($arguments)) {
         $requestString .= "/" . implode("/", $arguments);
     }
     $requestString .= "/read";
     echo $requestString . "\n";
     $request->handle($requestString);
 }
示例#4
0
<?php

/**
 * Demo of nested collections. DemoCountries merges DemoStates
 * and DemoStates merges DemoCities.
 * User: Alf Magne Kalleland
 * Date: 09.02.13
 * Time: 16:34
 */
require_once __DIR__ . "/autoload.php";
ini_set('display_errors', 'on');
date_default_timezone_set("Europe/Berlin");
LudoDB::setDb("PHPUnit");
LudoDB::setUser("root");
LudoDB::setPassword("administrator");
LudoDB::setHost("127.0.0.1");
$c = new DemoCountry();
if (!$c->exists()) {
    $util = new LudoDBUtility();
    $util->dropAndCreate(array("DemoState", "DemoCity", "DemoCountry"));
}
LudoDB::enableLogging();
// get number of queries and server time in response
$handler = new LudoDBRequestHandler();
echo $handler->handle("DemoCountries/read");
示例#5
0
 /**
  * @test
  */
 public function shouldReturnFormConfig()
 {
     // given
     $handler = new LudoDBRequestHandler();
     // when
     $form = $handler->handle("LudoJS/TLudoJSPerson/1/form");
     $form = json_decode($form, true);
     $formConfig = $form['response']['form'];
     $this->assertEquals('TLudoJSPerson', $formConfig['resource']);
 }
示例#6
0
<?php

require_once dirname(__FILE__) . "/autoload.php";
require_once "php/jsonwrapper/jsonwrapper.php";
date_default_timezone_set("Europe/Berlin");
ini_set('display_errors', 'on');
if (file_exists("connection.php")) {
    require "connection.php";
}
LudoDBRegistry::set('FILE_UPLOAD_PATH', '/tmp/');
LudoDBRegistry::set('DEVELOP_MODE', true);
LudoDB::enableLogging();
// For static(No db) installations
ChessRegistry::setPgnFolder("pgn");
ChessRegistry::setCacheFolder("cache");
// Path to cache
$request = isset($_GET['request']) ? $_GET['request'] : $_POST['request'];
$requestData = isset($_POST['data']) ? $_POST['data'] : null;
$handler = new LudoDBRequestHandler();
echo $handler->handle($request, $requestData);
<?php

/**
 * Template for a router, i.e. entry point for all requests sent by Ajax
 * from GUI.
 */
require_once __DIR__ . "/autoload.php";
date_default_timezone_set("Europe/Berlin");
header("Content-type: application/json");
LudoDB::setUser('root');
LudoDB::setPassword('administrator');
LudoDB::setHost('127.0.0.1');
LudoDB::setDb('PHPUnit');
$request = array('request' => isset($_GET['request']) ? $_GET['request'] : $_POST['request']);
if (isset($_POST['request'])) {
    $request['data'] = isset($_POST['request']['data']) ? $_POST['request']['data'] : $_POST['request'];
}
if (isset($_POST['arguments'])) {
    $request['arguments'] = $_POST['arguments'];
}
$handler = new LudoDBRequestHandler();
echo $handler->handle($request);