Skip to content

Commit

Permalink
– expanded tests
Browse files Browse the repository at this point in the history
– changed the autoloader function to throw an exception if the main global variable is not set
  • Loading branch information
uruba committed Aug 28, 2015
1 parent 0e697b7 commit f0c60ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/init/autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions tests/DebtAmortizatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,10 @@ public function testRoundMoneyFOrDisplayNegative() {
);
}

public function testIsObjectTypeInArrayFalse() {
$this->assertFalse(
isObjectTypeInArray('Fake', [])
);
}

}

0 comments on commit f0c60ba

Please sign in to comment.