Example #1
0
 private function getPgnFilesInQueuedFolder()
 {
     $folder = ChessRegistry::getImportQueueFolder();
     if (!isset($folder)) {
         throw new Exception("PGN folder not set using ChessRegistry::setImportQueueFolder");
     }
     return ChessFSPgn::getPgnFilesIn($folder);
 }
Example #2
0
 public function __construct($fen = null)
 {
     if (!isset($fen)) {
         $fen = ChessRegistry::getDefaultFen();
     }
     $this->fen = $this->getValidFen($fen);
     parent::__construct();
 }
Example #3
0
 /**
  * @test
  */
 public function shouldReturnNameOfPgnFilesInFolder()
 {
     // given
     ChessRegistry::setPgnFolder('pgn');
     $obj = new ChessFSPgn();
     $games = $obj->read();
     $this->assertEquals(3, count($games));
     $this->assertEquals('chessfs', $games[0]);
     $this->assertEquals('Lasker', $games[1]);
     $this->assertEquals('Morphy', $games[2]);
 }
Example #4
0
 private function getPgnPath($pgnFile)
 {
     $folder = ChessRegistry::getPgnFolder();
     if (isset($folder)) {
         $tokens = explode("/", $pgnFile);
         $pgnFile = $folder . array_pop($tokens);
     }
     if ($this->getExtension($pgnFile) !== 'pgn') {
         $pgnFile .= ".pgn";
     }
     return $pgnFile;
 }
Example #5
0
 public function read()
 {
     $folder = ChessRegistry::getPgnFolder();
     if (!isset($folder)) {
         throw new Exception("PGN folder not set using ChessRegistry::setPgnFolder");
     }
     $files = self::getPgnFilesIn($folder);
     $ret = array();
     $id = 1;
     foreach ($files as $file) {
         $ret[] = array("file" => $this->getNameOfFile($file), "id" => $id++);
     }
     return $ret;
 }
Example #6
0
 public function setUp()
 {
     ChessRegistry::setCacheFolder("/tmp");
 }
Example #7
0
 private function mockCookie($key)
 {
     $_COOKIE[ChessRegistry::getCookieName()] = $key;
 }
Example #8
0
 private static function getCookieValue()
 {
     if (isset(self::$cookieValue)) {
         return self::$cookieValue;
     }
     return isset($_COOKIE[ChessRegistry::getCookieName()]) ? $_COOKIE[ChessRegistry::getCookieName()] : null;
 }
Example #9
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);
Example #10
0
 /**
  * @test
  */
 public function shouldBeAbleToImportQueued()
 {
     // given
     copy("../../../pgn/fischer.pgn", "../../../import-queue/fischer.pgn");
     ChessRegistry::setImportQueueFolder("../../../import-queue/");
     $import = new GameImport(1);
     // when
     $import->importQueued();
     $db = new Database(1);
     $games = $db->games();
     // then
     $this->assertEquals(69, count($games));
     $this->assertFileNotExists("../../../import-queue/fischer.pgn");
 }
 private function getMessageBody()
 {
     return ChessRegistry::getPasswordResetBody() . $this->getValue("unique_key");
 }
Example #12
0
 protected function beforeInsert()
 {
     if (!$this->getFen()) {
         $this->setFen(ChessRegistry::getDefaultFen());
     }
 }