mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-05 20:18:42 +00:00
Bug fixes from tests
This commit is contained in:
parent
39635c1115
commit
dbe837a52e
|
|
@ -22,7 +22,7 @@ use phpOMS\Message\Http\Request;
|
||||||
use phpOMS\Message\RequestAbstract;
|
use phpOMS\Message\RequestAbstract;
|
||||||
use phpOMS\System\File\PathException;
|
use phpOMS\System\File\PathException;
|
||||||
use phpOMS\Module\Exception\InvalidModuleException;
|
use phpOMS\Module\Exception\InvalidModuleException;
|
||||||
use phpOMs\DataStorage\Database\Query\Builder;
|
use phpOMS\DataStorage\Database\Query\Builder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modules class.
|
* Modules class.
|
||||||
|
|
@ -143,7 +143,6 @@ final class ModuleManager
|
||||||
{
|
{
|
||||||
if ($this->uriLoad === null) {
|
if ($this->uriLoad === null) {
|
||||||
$uriHash = $request->getHash();
|
$uriHash = $request->getHash();
|
||||||
$uriPdo = '';
|
|
||||||
|
|
||||||
$query = new Builder($this->app->dbPool->get('select'));
|
$query = new Builder($this->app->dbPool->get('select'));
|
||||||
$query->prefix($this->app->dbPool->get('select')->prefix);
|
$query->prefix($this->app->dbPool->get('select')->prefix);
|
||||||
|
|
@ -183,12 +182,12 @@ final class ModuleManager
|
||||||
|
|
||||||
foreach ($active as $module) {
|
foreach ($active as $module) {
|
||||||
$path = $this->modulePath . '/' . $module . '/info.json';
|
$path = $this->modulePath . '/' . $module . '/info.json';
|
||||||
|
|
||||||
if (!\file_exists($path)) {
|
if (!\file_exists($path)) {
|
||||||
continue;
|
continue;
|
||||||
// throw new PathException($path);
|
// throw new PathException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = \file_get_contents($path);
|
$content = \file_get_contents($path);
|
||||||
$json = \json_decode($content === false ? '[]' : $content, true);
|
$json = \json_decode($content === false ? '[]' : $content, true);
|
||||||
$this->active[$json['name']['internal']] = $json === false ? [] : $json;
|
$this->active[$json['name']['internal']] = $json === false ? [] : $json;
|
||||||
|
|
@ -278,12 +277,12 @@ final class ModuleManager
|
||||||
|
|
||||||
foreach ($installed as $module) {
|
foreach ($installed as $module) {
|
||||||
$path = $this->modulePath . '/' . $module . '/info.json';
|
$path = $this->modulePath . '/' . $module . '/info.json';
|
||||||
|
|
||||||
if (!\file_exists($path)) {
|
if (!\file_exists($path)) {
|
||||||
continue;
|
continue;
|
||||||
// throw new PathException($path);
|
// throw new PathException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = \file_get_contents($path);
|
$content = \file_get_contents($path);
|
||||||
$json = \json_decode($content === false ? '[]' : $content, true);
|
$json = \json_decode($content === false ? '[]' : $content, true);
|
||||||
$this->installed[$json['name']['internal']] = $json === false ? [] : $json;
|
$this->installed[$json['name']['internal']] = $json === false ? [] : $json;
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ class Currency
|
||||||
public static function getEcbEuroRates() : array
|
public static function getEcbEuroRates() : array
|
||||||
{
|
{
|
||||||
if (!isset(self::$ecbCurrencies)) {
|
if (!isset(self::$ecbCurrencies)) {
|
||||||
$request = new Request(new Http('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'));
|
$request = new Request(new Http('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml'));
|
||||||
$request->setMethod(RequestMethod::GET);
|
$request->setMethod(RequestMethod::GET);
|
||||||
|
|
||||||
$xml = new \SimpleXMLElement(Rest::request($request));
|
$xml = new \SimpleXMLElement(Rest::request($request));
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ final class StringCompare
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($words1 as $word1) {
|
foreach ($words1 as $word1) {
|
||||||
|
// todo: is this correct?
|
||||||
$best = \strlen($s2);
|
$best = \strlen($s2);
|
||||||
|
|
||||||
foreach ($words2 as $word2) {
|
foreach ($words2 as $word2) {
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ class ErrorTest extends \PHPUnit\Framework\TestCase
|
||||||
public function testScaledError()
|
public function testScaledError()
|
||||||
{
|
{
|
||||||
self::assertEquals(
|
self::assertEquals(
|
||||||
[Error::getScaledError(Error::getForecastError(1000, 700), 1000)],
|
[Error::getScaledError(Error::getForecastError(1000, 700), [1000, 800])],
|
||||||
Error::getScaledErrorArray([Error::getForecastError(1000, 700)], [1000])
|
Error::getScaledErrorArray([Error::getForecastError(1000, 700)], [1000, 800])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,14 @@ class CommitTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals([
|
self::assertEquals([
|
||||||
'/some/file/path2' => []
|
'/some/file/path2' => []
|
||||||
], $commit->getFiles());
|
], $commit->getFiles());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testChanges()
|
||||||
|
{
|
||||||
|
$commit = new Commit();
|
||||||
|
|
||||||
$commit->addChanges(__DIR__ . '/CommitTest.php', 1, '<?php', 'test');
|
$commit->addChanges(__DIR__ . '/CommitTest.php', 1, '<?php', 'test');
|
||||||
self::assertTrue(
|
self::assertEquals(
|
||||||
[
|
[
|
||||||
__DIR__ . '/CommitTest.php' => [
|
__DIR__ . '/CommitTest.php' => [
|
||||||
1 => [
|
1 => [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user