private function getPgnFilesInQueuedFolder() { $folder = ChessRegistry::getImportQueueFolder(); if (!isset($folder)) { throw new Exception("PGN folder not set using ChessRegistry::setImportQueueFolder"); } return ChessFSPgn::getPgnFilesIn($folder); }
public function __construct($fen = null) { if (!isset($fen)) { $fen = ChessRegistry::getDefaultFen(); } $this->fen = $this->getValidFen($fen); parent::__construct(); }
/** * @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]); }
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; }
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; }
public function setUp() { ChessRegistry::setCacheFolder("/tmp"); }
private function mockCookie($key) { $_COOKIE[ChessRegistry::getCookieName()] = $key; }
private static function getCookieValue() { if (isset(self::$cookieValue)) { return self::$cookieValue; } return isset($_COOKIE[ChessRegistry::getCookieName()]) ? $_COOKIE[ChessRegistry::getCookieName()] : null; }
<?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);
/** * @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"); }
protected function beforeInsert() { if (!$this->getFen()) { $this->setFen(ChessRegistry::getDefaultFen()); } }