From f0c60ba4132dc86e2d78d1169ff717fc511796b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Uruba?= Date: Fri, 28 Aug 2015 20:22:13 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=93=20expanded=20tests=20=E2=80=93=20chan?= =?UTF-8?q?ged=20the=20autoloader=20function=20to=20throw=20an=20exception?= =?UTF-8?q?=20if=20the=20main=20global=20variable=20is=20not=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/init/autoloader.php | 4 +--- tests/DebtAmortizatorTest.php | 18 ++++++++++++++++++ tests/HelpersTest.php | 6 ++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/init/autoloader.php b/src/init/autoloader.php index 3eb76e2..f2fae01 100644 --- a/src/init/autoloader.php +++ b/src/init/autoloader.php @@ -2,9 +2,7 @@ spl_autoload_register(function($class) { if (!isset($GLOBALS['FINANCALC_ROOT'])) { - return; - - // throw new Exception('Global variable containing path to the library root has not been set.'); + throw new Exception('Global variable containing path to the library root has not been set.'); } $exploded_class = explode("\\", $class); diff --git a/tests/DebtAmortizatorTest.php b/tests/DebtAmortizatorTest.php index 1fa81d3..7bb2044 100644 --- a/tests/DebtAmortizatorTest.php +++ b/tests/DebtAmortizatorTest.php @@ -26,6 +26,24 @@ public function testRepaymentsFactoryYearly() { $this->processResult($debtAmortizatorFactory); $this->processArray($debtAmortizatorFactory->getResultAsArray()); + + // test setters and getters by assigning mock values + $debtAmortizatorFactory->setDebtPrincipal(1); + $debtAmortizatorFactory->setDebtNoOfCompoundingPeriods(2); + $debtAmortizatorFactory->setDebtInterest(3); + + $this->assertEquals( + 1, + $debtAmortizatorFactory->getDebtPrincipal() + ); + $this->assertEquals( + 2, + $debtAmortizatorFactory->getDebtNoOfCompoundingPeriods() + ); + $this->assertEquals( + 3, + $debtAmortizatorFactory->getDebtInterest() + ); } /** diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php index ff6bf9b..ba50746 100644 --- a/tests/HelpersTest.php +++ b/tests/HelpersTest.php @@ -162,4 +162,10 @@ public function testRoundMoneyFOrDisplayNegative() { ); } + public function testIsObjectTypeInArrayFalse() { + $this->assertFalse( + isObjectTypeInArray('Fake', []) + ); + } + }