From dbe837a52e32d58c1ac1cbebcc3d8a362a990c4e Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 8 Sep 2018 19:06:42 +0200 Subject: [PATCH] Bug fixes from tests --- Module/ModuleManager.php | 11 +++++------ Utils/Converter/Currency.php | 2 +- Utils/StringCompare.php | 1 + tests/Math/Statistic/Forecast/ErrorTest.php | 4 ++-- tests/Utils/Git/CommitTest.php | 7 ++++++- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Module/ModuleManager.php b/Module/ModuleManager.php index d35aabedb..a87e0beee 100644 --- a/Module/ModuleManager.php +++ b/Module/ModuleManager.php @@ -22,7 +22,7 @@ use phpOMS\Message\Http\Request; use phpOMS\Message\RequestAbstract; use phpOMS\System\File\PathException; use phpOMS\Module\Exception\InvalidModuleException; -use phpOMs\DataStorage\Database\Query\Builder; +use phpOMS\DataStorage\Database\Query\Builder; /** * Modules class. @@ -143,7 +143,6 @@ final class ModuleManager { if ($this->uriLoad === null) { $uriHash = $request->getHash(); - $uriPdo = ''; $query = new Builder($this->app->dbPool->get('select')); $query->prefix($this->app->dbPool->get('select')->prefix); @@ -183,12 +182,12 @@ final class ModuleManager foreach ($active as $module) { $path = $this->modulePath . '/' . $module . '/info.json'; - + if (!\file_exists($path)) { continue; // throw new PathException($path); } - + $content = \file_get_contents($path); $json = \json_decode($content === false ? '[]' : $content, true); $this->active[$json['name']['internal']] = $json === false ? [] : $json; @@ -278,12 +277,12 @@ final class ModuleManager foreach ($installed as $module) { $path = $this->modulePath . '/' . $module . '/info.json'; - + if (!\file_exists($path)) { continue; // throw new PathException($path); } - + $content = \file_get_contents($path); $json = \json_decode($content === false ? '[]' : $content, true); $this->installed[$json['name']['internal']] = $json === false ? [] : $json; diff --git a/Utils/Converter/Currency.php b/Utils/Converter/Currency.php index 38a35fa46..77b270d7b 100644 --- a/Utils/Converter/Currency.php +++ b/Utils/Converter/Currency.php @@ -97,7 +97,7 @@ class Currency public static function getEcbEuroRates() : array { 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); $xml = new \SimpleXMLElement(Rest::request($request)); diff --git a/Utils/StringCompare.php b/Utils/StringCompare.php index 7918f6d31..ecd2c0bbb 100644 --- a/Utils/StringCompare.php +++ b/Utils/StringCompare.php @@ -107,6 +107,7 @@ final class StringCompare } foreach ($words1 as $word1) { + // todo: is this correct? $best = \strlen($s2); foreach ($words2 as $word2) { diff --git a/tests/Math/Statistic/Forecast/ErrorTest.php b/tests/Math/Statistic/Forecast/ErrorTest.php index 2a0003309..b6f697518 100644 --- a/tests/Math/Statistic/Forecast/ErrorTest.php +++ b/tests/Math/Statistic/Forecast/ErrorTest.php @@ -91,8 +91,8 @@ class ErrorTest extends \PHPUnit\Framework\TestCase public function testScaledError() { self::assertEquals( - [Error::getScaledError(Error::getForecastError(1000, 700), 1000)], - Error::getScaledErrorArray([Error::getForecastError(1000, 700)], [1000]) + [Error::getScaledError(Error::getForecastError(1000, 700), [1000, 800])], + Error::getScaledErrorArray([Error::getForecastError(1000, 700)], [1000, 800]) ); } } diff --git a/tests/Utils/Git/CommitTest.php b/tests/Utils/Git/CommitTest.php index f90b7728d..e332d0494 100644 --- a/tests/Utils/Git/CommitTest.php +++ b/tests/Utils/Git/CommitTest.php @@ -51,9 +51,14 @@ class CommitTest extends \PHPUnit\Framework\TestCase self::assertEquals([ '/some/file/path2' => [] ], $commit->getFiles()); + } + + public function testChanges() + { + $commit = new Commit(); $commit->addChanges(__DIR__ . '/CommitTest.php', 1, ' [ 1 => [