Minor code cleanup
This commit is contained in:
parent
eeb7ec7532
commit
cd5255cbb8
@ -35,8 +35,8 @@ class UloggerAPITestCase extends BaseDatabaseTestCase {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticate on server
|
* Authenticate on server
|
||||||
* @param string $user Login
|
* @param string|null $user Login (defaults to test user)
|
||||||
*
|
* @param string|null $pass Optional password (defaults to test password)
|
||||||
* @return bool true on success, false otherwise
|
* @return bool true on success, false otherwise
|
||||||
*/
|
*/
|
||||||
public function authenticate($user = NULL, $pass = NULL) {
|
public function authenticate($user = NULL, $pass = NULL) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
require_once(__DIR__ . "/../lib/UloggerAPITestCase.php");
|
require_once(__DIR__ . "/../lib/UloggerAPITestCase.php");
|
||||||
if (!defined("ROOT_DIR")) { define("ROOT_DIR", __DIR__ . "/../.."); }
|
if (!defined("ROOT_DIR")) { define("ROOT_DIR", __DIR__ . "/../.."); }
|
||||||
require_once(ROOT_DIR . "/helpers/config.php");
|
require_once(ROOT_DIR . "/helpers/config.php");
|
||||||
@ -788,7 +790,10 @@ class ImportTest extends UloggerAPITestCase {
|
|||||||
$this->assertEquals(0, $this->getConnection()->getRowCount("positions"), "Wrong row count");
|
$this->assertEquals(0, $this->getConnection()->getRowCount("positions"), "Wrong row count");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ResponseInterface $response
|
||||||
|
* @return bool|SimpleXMLElement
|
||||||
|
*/
|
||||||
private function getXMLfromResponse($response) {
|
private function getXMLfromResponse($response) {
|
||||||
$xml = false;
|
$xml = false;
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
require_once(__DIR__ . "/../lib/UloggerAPITestCase.php");
|
require_once(__DIR__ . "/../lib/UloggerAPITestCase.php");
|
||||||
if (!defined("ROOT_DIR")) { define("ROOT_DIR", __DIR__ . "/../.."); }
|
if (!defined("ROOT_DIR")) { define("ROOT_DIR", __DIR__ . "/../.."); }
|
||||||
require_once(ROOT_DIR . "/helpers/config.php");
|
require_once(ROOT_DIR . "/helpers/config.php");
|
||||||
@ -964,7 +966,10 @@ class InternalAPITest extends UloggerAPITestCase {
|
|||||||
$this->assertEquals(1, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
$this->assertEquals(1, $this->getConnection()->getRowCount("users"), "Wrong row count");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ResponseInterface $response
|
||||||
|
* @return bool|SimpleXMLElement
|
||||||
|
*/
|
||||||
private function getXMLfromResponse($response) {
|
private function getXMLfromResponse($response) {
|
||||||
$xml = false;
|
$xml = false;
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
|
@ -133,7 +133,7 @@ class PositionTest extends UloggerDatabaseTestCase {
|
|||||||
$this->assertEquals($trackId2, $position->trackId);
|
$this->assertEquals($trackId2, $position->trackId);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->assert("Unexpected position: {$position->id}");
|
$this->assertTrue(false, "Unexpected position: {$position->id}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
"ulrichsg/getopt-php": "^3.2",
|
"ulrichsg/getopt-php": "^3.2",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-xmlwriter": "*"
|
"ext-xmlwriter": "*",
|
||||||
|
"ext-simplexml": "*",
|
||||||
|
"ext-libxml": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "./vendor/bin/phpunit"
|
"test": "./vendor/bin/phpunit"
|
||||||
@ -13,6 +15,5 @@
|
|||||||
"vlucas/phpdotenv": "^3.3",
|
"vlucas/phpdotenv": "^3.3",
|
||||||
"guzzlehttp/guzzle": "^6.3",
|
"guzzlehttp/guzzle": "^6.3",
|
||||||
"phpunit/dbunit": "^2.0"
|
"phpunit/dbunit": "^2.0"
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
class uAuth {
|
class uAuth {
|
||||||
|
|
||||||
private $isAuthenticated = false;
|
private $isAuthenticated = false;
|
||||||
|
/** @var null|uUser */
|
||||||
public $user = null;
|
public $user = null;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
@ -105,9 +106,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process log in request
|
* Check valid pass for given login
|
||||||
*
|
*
|
||||||
* @return void
|
* @param $login
|
||||||
|
* @param $pass
|
||||||
|
* @return boolean True if valid
|
||||||
*/
|
*/
|
||||||
public function checkLogin($login, $pass) {
|
public function checkLogin($login, $pass) {
|
||||||
if (!is_null($login) && !is_null($pass)) {
|
if (!is_null($login) && !is_null($pass)) {
|
||||||
|
@ -57,8 +57,6 @@
|
|||||||
|
|
||||||
public $isValid = false;
|
public $isValid = false;
|
||||||
|
|
||||||
private static $db;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
* @param integer $positionId Position id
|
* @param integer $positionId Position id
|
||||||
@ -235,7 +233,7 @@
|
|||||||
*
|
*
|
||||||
* @param int $userId Optional limit to given user id
|
* @param int $userId Optional limit to given user id
|
||||||
* @param int $trackId Optional limit to given track id
|
* @param int $trackId Optional limit to given track id
|
||||||
* @return array|bool Array of uPosition positions, false on error
|
* @return uPosition[]|bool Array of uPosition positions, false on error
|
||||||
*/
|
*/
|
||||||
public static function getAll($userId = NULL, $trackId = NULL) {
|
public static function getAll($userId = NULL, $trackId = NULL) {
|
||||||
$rules = [];
|
$rules = [];
|
||||||
|
@ -31,11 +31,6 @@
|
|||||||
|
|
||||||
public $isValid = false;
|
public $isValid = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var uDb $db
|
|
||||||
*/
|
|
||||||
private static $db = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -34,8 +34,6 @@
|
|||||||
public $isAdmin = false;
|
public $isAdmin = false;
|
||||||
public $isValid = false;
|
public $isValid = false;
|
||||||
|
|
||||||
private static $db = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@ -47,7 +47,7 @@ $getopt->addOptions([
|
|||||||
Option::create('h', 'help')
|
Option::create('h', 'help')
|
||||||
->setDescription('Show usage/help'),
|
->setDescription('Show usage/help'),
|
||||||
|
|
||||||
Option::create('u', 'user-id', \GetOpt\GetOpt::OPTIONAL_ARGUMENT)
|
Option::create('u', 'user-id', GetOpt::OPTIONAL_ARGUMENT)
|
||||||
->setDescription('Which user to import the track(s) for (default: 1)')
|
->setDescription('Which user to import the track(s) for (default: 1)')
|
||||||
->setDefaultValue(1)
|
->setDefaultValue(1)
|
||||||
->setValidation('is_numeric', '%s has to be an integer'),
|
->setValidation('is_numeric', '%s has to be an integer'),
|
||||||
@ -60,7 +60,7 @@ $getopt->addOptions([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$getopt->addOperand(
|
$getopt->addOperand(
|
||||||
Operand::create('gpx', \GetOpt\Operand::MULTIPLE + \GetOpt\Operand::REQUIRED)
|
Operand::create('gpx', Operand::MULTIPLE + Operand::REQUIRED)
|
||||||
->setDescription('One or more GPX files to import')
|
->setDescription('One or more GPX files to import')
|
||||||
->setValidation('is_readable', '%s: %s is not readable')
|
->setValidation('is_readable', '%s: %s is not readable')
|
||||||
);
|
);
|
||||||
|
@ -123,7 +123,6 @@ if ($trackId && $userId) {
|
|||||||
$totalSeconds = 0;
|
$totalSeconds = 0;
|
||||||
$coordinate = [];
|
$coordinate = [];
|
||||||
foreach ($positionsArr as $position) {
|
foreach ($positionsArr as $position) {
|
||||||
/** @var uPosition $prevPosition */
|
|
||||||
$distance = isset($prevPosition) ? $position->distanceTo($prevPosition) : 0;
|
$distance = isset($prevPosition) ? $position->distanceTo($prevPosition) : 0;
|
||||||
$seconds = isset($prevPosition) ? $position->secondsTo($prevPosition) : 0;
|
$seconds = isset($prevPosition) ? $position->secondsTo($prevPosition) : 0;
|
||||||
$prevPosition = $position;
|
$prevPosition = $position;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user