diff --git a/Account/NullGroup.php b/Account/NullGroup.php new file mode 100644 index 000000000..0baee204f --- /dev/null +++ b/Account/NullGroup.php @@ -0,0 +1,27 @@ + $r Rate of return * @@ -1252,7 +1254,7 @@ final class FinanceFormulas * * @since 1.0.0 */ - public static function getRateOfOnflation(float $newCPI, float $oldCPI) : float + public static function getRateOfInflation(float $newCPI, float $oldCPI) : float { return $newCPI / $oldCPI - 1; } diff --git a/tests/Account/NullGroupTest.php b/tests/Account/NullGroupTest.php new file mode 100644 index 000000000..4ed9e5e2c --- /dev/null +++ b/tests/Account/NullGroupTest.php @@ -0,0 +1,30 @@ +getName()); } - public function testSetGet() : void + /** + * @testdox Coordinates of a point can be changed + */ + public function testChangeCoordinates() : void { $point = new Point([3.0, 2.0], 'abc'); @@ -44,6 +50,14 @@ class PointTest extends \PHPUnit\Framework\TestCase self::assertEquals([4.0, 1.0], $point->getCoordinates()); self::assertEquals(4.0, $point->getCoordinate(0)); self::assertEquals(1.0, $point->getCoordinate(1)); + } + + /** + * @testdox The group/cluster of a point can be changed + */ + public function testChangeGroup() : void + { + $point = new Point([3.0, 2.0], 'abc'); $point->setGroup(2); self::assertEquals(2, $point->getGroup()); diff --git a/tests/Algorithm/CoinMatching/MinimumCoinProblemTest.php b/tests/Algorithm/CoinMatching/MinimumCoinProblemTest.php index 1e6310900..9a1b892a2 100644 --- a/tests/Algorithm/CoinMatching/MinimumCoinProblemTest.php +++ b/tests/Algorithm/CoinMatching/MinimumCoinProblemTest.php @@ -12,19 +12,22 @@ */ declare(strict_types=1); -namespace phpOMS\Algorithm\CoinMatching; +namespace phpOMS\tests\Algorithm\CoinMatching; use phpOMS\Algorithm\CoinMatching\MinimumCoinProblem; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\Algorithm\CoinMatching\MinimumCoinProblem: Test coin matching a value problem + * @testdox phpOMS\tests\Algorithm\CoinMatching\MinimumCoinProblemTest: Match a value by using the minimum quantity of available sub values (Minimum Coin Problem) * * @internal */ class MinimumCoinProblemTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox A value is matched with the minimum quantity of avialable coins. + */ public function testMinimumCoins() : void { self::assertEquals( diff --git a/tests/Algorithm/JobScheduling/JobTest.php b/tests/Algorithm/JobScheduling/JobTest.php index 60912a1b5..2ee0d506d 100644 --- a/tests/Algorithm/JobScheduling/JobTest.php +++ b/tests/Algorithm/JobScheduling/JobTest.php @@ -12,17 +12,20 @@ */ declare(strict_types=1); -namespace phpOMS\Algorithm\JobScheduling; +namespace phpOMS\tests\Algorithm\JobScheduling; use phpOMS\Algorithm\JobScheduling\Job; /** - * @testdox phpOMS\Algorithm\JobScheduling\Job: Test the job for the JobScheduling implementations + * @testdox phpOMS\tests\Algorithm\JobScheduling\JobTest: Default job for the job scheduling * * @internal */ class JobTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The job has the expected values after initialization + */ public function testDefault() : void { $item = new Job(3.0, new \DateTime('now'), null, 'abc'); diff --git a/tests/Algorithm/JobScheduling/WeightedTest.php b/tests/Algorithm/JobScheduling/WeightedTest.php index 752b07ace..af33db637 100644 --- a/tests/Algorithm/JobScheduling/WeightedTest.php +++ b/tests/Algorithm/JobScheduling/WeightedTest.php @@ -12,18 +12,22 @@ */ declare(strict_types=1); -namespace phpOMS\Algorithm\JobScheduling; +namespace phpOMS\tests\Algorithm\JobScheduling; use phpOMS\Algorithm\JobScheduling\Weighted; +use phpOMS\Algorithm\JobScheduling\Job; /** - * @testdox phpOMS\Algorithm\JobScheduling\Weighted: Test the job for the JobScheduling implementations + * @testdox phpOMS\tests\Algorithm\JobScheduling\WeightedTest: Job scheduling based on values/profit * * @internal */ class WeightedTest extends \PHPUnit\Framework\TestCase { - public function testDefault() : void + /** + * @testdox The optimal job combination is selected to maximize the value/profit without overlapping jobs + */ + public function testNoOverlappingScheduling() : void { $jobs = [ new Job(20, new \DateTime('2003-01-01'), new \DateTime('2010-01-01'), 'A'), @@ -50,6 +54,9 @@ class WeightedTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A job list with only one job simply returns one job + */ public function testSmallList() : void { $jobs = [ diff --git a/tests/Algorithm/Knapsack/BackpackTest.php b/tests/Algorithm/Knapsack/BackpackTest.php index 2630d3d5b..3e5e30dc5 100644 --- a/tests/Algorithm/Knapsack/BackpackTest.php +++ b/tests/Algorithm/Knapsack/BackpackTest.php @@ -12,17 +12,21 @@ */ declare(strict_types=1); -namespace phpOMS\Algorithm\Knapsack; +namespace phpOMS\tests\Algorithm\Knapsack; use phpOMS\Algorithm\Knapsack\Backpack; +use phpOMS\Algorithm\Knapsack\Item; /** - * @testdox phpOMS\Algorithm\Knapsack\Backpack: Test the backpack for the Knapsack implementations + * @testdox phpOMS\tests\Algorithm\Knapsack\BackpackTest: The default backpack or basket which holds all items for the Knapsack algorithm * * @internal */ class BackpackTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The backpack has the expected values after initialization + */ public function testDefault() : void { $backpack = new Backpack(3.0); @@ -33,7 +37,10 @@ class BackpackTest extends \PHPUnit\Framework\TestCase self::assertEquals([], $backpack->getItems()); } - public function testGetSet() : void + /** + * @testdox Items can be added to the backpack and automatically change the value and cost the backpack contains + */ + public function testAddItems() : void { $backpack = new Backpack(3.0); $backpack->addItem(new Item(2, 1), 2); diff --git a/tests/Algorithm/Knapsack/BoundedTest.php b/tests/Algorithm/Knapsack/BoundedTest.php index 3038ca8f8..35b83b7aa 100644 --- a/tests/Algorithm/Knapsack/BoundedTest.php +++ b/tests/Algorithm/Knapsack/BoundedTest.php @@ -12,17 +12,22 @@ */ declare(strict_types=1); -namespace phpOMS\Algorithm\Knapsack; +namespace phpOMS\tests\Algorithm\Knapsack; use phpOMS\Algorithm\Knapsack\Bounded; +use phpOMS\Algorithm\Knapsack\Backpack; +use phpOMS\Algorithm\Knapsack\Item; /** - * @testdox phpOMS\Algorithm\Knapsack\Bounded: Test the continuous Knapsack implementations + * @testdox phpOMS\tests\Algorithm\Knapsack\BoundedTest: A Knapsack implementation for discrete quantities, values and costs and bounded item quantities * * @internal */ class BoundedTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit + */ public function testBackpacking() : void { $items = [ diff --git a/tests/Algorithm/Knapsack/ContinuousTest.php b/tests/Algorithm/Knapsack/ContinuousTest.php index f08fcc9a8..9e0cc2248 100644 --- a/tests/Algorithm/Knapsack/ContinuousTest.php +++ b/tests/Algorithm/Knapsack/ContinuousTest.php @@ -12,17 +12,22 @@ */ declare(strict_types=1); -namespace phpOMS\Algorithm\Knapsack; +namespace phpOMS\tests\Algorithm\Knapsack; use phpOMS\Algorithm\Knapsack\Continuous; +use phpOMS\Algorithm\Knapsack\Backpack; +use phpOMS\Algorithm\Knapsack\Item; /** - * @testdox phpOMS\Algorithm\Knapsack\Continuous: Test the continuous Knapsack implementations + * @testdox phpOMS\tests\Algorithm\Knapsack\ContinuousTest: A Knapsack implementation for continuous quantities, values and costs * * @internal */ class ContinuousTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit [discrete quantities] + */ public function testBackpacking() : void { $items = [ @@ -60,6 +65,9 @@ class ContinuousTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox The optimal item selection in a backpack is calculated in order to optimize the value/profit while considering the available capacity/cost limit [continuous quantities] + */ public function testBackpackingAlternative() : void { $items = [ diff --git a/tests/Algorithm/Knapsack/ItemTest.php b/tests/Algorithm/Knapsack/ItemTest.php index 1d107bcc0..d19ef8228 100644 --- a/tests/Algorithm/Knapsack/ItemTest.php +++ b/tests/Algorithm/Knapsack/ItemTest.php @@ -12,17 +12,20 @@ */ declare(strict_types=1); -namespace phpOMS\Algorithm\Knapsack; +namespace phpOMS\tests\Algorithm\Knapsack; use phpOMS\Algorithm\Knapsack\Item; /** - * @testdox phpOMS\Algorithm\Knapsack\Item: Test the item for the Knapsack implementations + * @testdox phpOMS\tests\Algorithm\Knapsack\ItemTest: The default item to be added to the backpack or basket * * @internal */ class ItemTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The item has the expected values after initialization + */ public function testDefault() : void { $item = new Item(3.0, 2.0, 'abc'); diff --git a/tests/Algorithm/PathFinding/AStarTest.php b/tests/Algorithm/PathFinding/AStarTest.php index 8997e2841..77d3dccfe 100644 --- a/tests/Algorithm/PathFinding/AStarTest.php +++ b/tests/Algorithm/PathFinding/AStarTest.php @@ -23,7 +23,7 @@ use phpOMS\Algorithm\PathFinding\AStar; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\PathFinding: jump point search test + * @testdox phpOMS\tests\Algorithm\PathFinding\AStarTest: AStar path finding * * @internal */ @@ -67,6 +67,9 @@ class AStarTest extends \PHPUnit\Framework\TestCase } } + /** + * @testdox The correct path is found for diagonal movement + */ public function testPathFindingDiagonal() : void { $grid = Grid::createGridFromArray($this->gridArray, AStarNode::class); @@ -106,6 +109,9 @@ class AStarTest extends \PHPUnit\Framework\TestCase ], $this->gridArray); } + /** + * @testdox The correct path is found for straight movement + */ public function testPathFindingStraight() : void { $grid = Grid::createGridFromArray($this->gridArray, AStarNode::class); @@ -145,6 +151,9 @@ class AStarTest extends \PHPUnit\Framework\TestCase ], $this->gridArray); } + /** + * @testdox The correct path is found for diagonal movement [one obstacle] + */ public function testPathFindingDiagonalOneObstacle() : void { $grid = Grid::createGridFromArray($this->gridArray, AStarNode::class); @@ -184,6 +193,9 @@ class AStarTest extends \PHPUnit\Framework\TestCase ], $this->gridArray); } + /** + * @testdox The correct path is found for diagonal movement [no obstacle] + */ public function testPathFindingDiagonalNoObstacle() : void { $grid = Grid::createGridFromArray($this->gridArray, AStarNode::class); diff --git a/tests/Algorithm/PathFinding/JumpPointSearchTest.php b/tests/Algorithm/PathFinding/JumpPointSearchTest.php index 10f484f6e..1acca0cf4 100644 --- a/tests/Algorithm/PathFinding/JumpPointSearchTest.php +++ b/tests/Algorithm/PathFinding/JumpPointSearchTest.php @@ -23,7 +23,7 @@ use phpOMS\Algorithm\PathFinding\JumpPointSearch; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\PathFinding: jump point search test + * @testdox phpOMS\tests\Algorithm\PathFinding\JumpPointSearchTest: JumpPoint path finding * * @internal */ @@ -67,6 +67,9 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase } } + /** + * @testdox The correct path is found for diagonal movement + */ public function testPathFindingDiagonal() : void { $grid = Grid::createGridFromArray($this->gridArray, JumpPointNode::class); @@ -106,6 +109,9 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase ], $this->gridArray); } + /** + * @testdox The correct path is found for straight movement + */ public function testPathFindingStraight() : void { $grid = Grid::createGridFromArray($this->gridArray, JumpPointNode::class); @@ -145,6 +151,9 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase ], $this->gridArray); } + /** + * @testdox The correct path is found for diagonal movement [one obstacle] + */ public function testPathFindingDiagonalOneObstacle() : void { $grid = Grid::createGridFromArray($this->gridArray, JumpPointNode::class); @@ -184,6 +193,9 @@ class JumpPointSearchTest extends \PHPUnit\Framework\TestCase ], $this->gridArray); } + /** + * @testdox The correct path is found for diagonal movement [no obstacle] + */ public function testPathFindingDiagonalNoObstacle() : void { $grid = Grid::createGridFromArray($this->gridArray, JumpPointNode::class); diff --git a/tests/Algorithm/Sort/BitonicSortTest.php b/tests/Algorithm/Sort/BitonicSortTest.php index 7a882b4f5..7da438e1c 100644 --- a/tests/Algorithm/Sort/BitonicSortTest.php +++ b/tests/Algorithm/Sort/BitonicSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Bitonic sort test + * @testdox phpOMS\tests\Algorithm\Sort\BitonicSortTest: Bitonic sort * * @internal */ @@ -38,6 +38,9 @@ class BitonicSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -46,6 +49,9 @@ class BitonicSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = BitonicSort::sort($this->list); @@ -58,6 +64,9 @@ class BitonicSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = BitonicSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/BubbleSortTest.php b/tests/Algorithm/Sort/BubbleSortTest.php index d1df8641c..2fddebd99 100644 --- a/tests/Algorithm/Sort/BubbleSortTest.php +++ b/tests/Algorithm/Sort/BubbleSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Bubble sort test + * @testdox phpOMS\tests\Algorithm\Sort\BubbleSortTest: Bubble sort * * @internal */ @@ -39,6 +39,9 @@ class BubbleSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class BubbleSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = BubbleSort::sort($this->list); @@ -59,6 +65,9 @@ class BubbleSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = BubbleSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/BucketSortTest.php b/tests/Algorithm/Sort/BucketSortTest.php index f53b28590..ad4b86b16 100644 --- a/tests/Algorithm/Sort/BucketSortTest.php +++ b/tests/Algorithm/Sort/BucketSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Bucket sort test + * @testdox phpOMS\tests\Algorithm\Sort\BucketSortTest: Bucket sort * * @internal */ @@ -39,6 +39,9 @@ class BucketSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class BucketSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = BucketSort::sort($this->list, 2, \phpOMS\Algorithm\Sort\SelectionSort::class); @@ -59,6 +65,9 @@ class BucketSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = BucketSort::sort($this->list, 2, \phpOMS\Algorithm\Sort\SelectionSort::class, SortOrder::DESC); @@ -71,6 +80,9 @@ class BucketSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox If no buckets are specified the elements cannot be sorted and an empty result is returned + */ public function testNoBuckets() : void { $newList = BucketSort::sort($this->list, 0, \phpOMS\Algorithm\Sort\SelectionSort::class); diff --git a/tests/Algorithm/Sort/CocktailShakerSortTest.php b/tests/Algorithm/Sort/CocktailShakerSortTest.php index 17a19419c..1b6cb3832 100644 --- a/tests/Algorithm/Sort/CocktailShakerSortTest.php +++ b/tests/Algorithm/Sort/CocktailShakerSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: CocktailShaker sort test + * @testdox phpOMS\tests\Algorithm\Sort\CocktailShakerSortTest: CocktailShaker sort * * @internal */ @@ -39,6 +39,9 @@ class CocktailShakerSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class CocktailShakerSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = CocktailShakerSort::sort($this->list); @@ -59,6 +65,9 @@ class CocktailShakerSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = CocktailShakerSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/CombSortTest.php b/tests/Algorithm/Sort/CombSortTest.php index 00063f81e..bb846279f 100644 --- a/tests/Algorithm/Sort/CombSortTest.php +++ b/tests/Algorithm/Sort/CombSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Comb sort test + * @testdox phpOMS\tests\Algorithm\Sort\CombSortTest: Comb sort * * @internal */ @@ -39,6 +39,9 @@ class CombSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class CombSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = CombSort::sort($this->list); @@ -59,6 +65,9 @@ class CombSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = CombSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/CycleSortTest.php b/tests/Algorithm/Sort/CycleSortTest.php index d05d47e9a..3ca728b87 100644 --- a/tests/Algorithm/Sort/CycleSortTest.php +++ b/tests/Algorithm/Sort/CycleSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Cycle sort test + * @testdox phpOMS\tests\Algorithm\Sort\CycleSortTest: Cycle sort * * @internal */ @@ -39,6 +39,9 @@ class CycleSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class CycleSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = CycleSort::sort($this->list); @@ -59,6 +65,9 @@ class CycleSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = CycleSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/GnomeSortTest.php b/tests/Algorithm/Sort/GnomeSortTest.php index 623d7baca..471dae9d6 100644 --- a/tests/Algorithm/Sort/GnomeSortTest.php +++ b/tests/Algorithm/Sort/GnomeSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Gnome sort test + * @testdox phpOMS\tests\Algorithm\Sort\GnomeSortTest: Gnome sort * * @internal */ @@ -39,6 +39,9 @@ class GnomeSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class GnomeSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = GnomeSort::sort($this->list); @@ -59,6 +65,9 @@ class GnomeSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = GnomeSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/HeapSortTest.php b/tests/Algorithm/Sort/HeapSortTest.php index 121842717..7e06dbce0 100644 --- a/tests/Algorithm/Sort/HeapSortTest.php +++ b/tests/Algorithm/Sort/HeapSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Heap sort test + * @testdox phpOMS\tests\Algorithm\Sort\HeapSortTest: Heap sort * * @internal */ @@ -39,6 +39,9 @@ class HeapSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class HeapSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = HeapSort::sort($this->list); @@ -59,6 +65,9 @@ class HeapSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = HeapSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/InsertionSortTest.php b/tests/Algorithm/Sort/InsertionSortTest.php index 06b74ca89..05a32998d 100644 --- a/tests/Algorithm/Sort/InsertionSortTest.php +++ b/tests/Algorithm/Sort/InsertionSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Insertion sort test + * @testdox phpOMS\tests\Algorithm\Sort\InsertionSortTest: Insertion sort * * @internal */ @@ -39,6 +39,9 @@ class InsertionSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class InsertionSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = InsertionSort::sort($this->list); @@ -59,6 +65,9 @@ class InsertionSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = InsertionSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/IntroSortTest.php b/tests/Algorithm/Sort/IntroSortTest.php index edbb4b0c4..835e0b256 100644 --- a/tests/Algorithm/Sort/IntroSortTest.php +++ b/tests/Algorithm/Sort/IntroSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Intro sort test + * @testdox phpOMS\tests\Algorithm\Sort\IntroSortTest: Intro sort * * @internal */ @@ -39,6 +39,9 @@ class IntroSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class IntroSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = IntroSort::sort($this->list); @@ -59,6 +65,9 @@ class IntroSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = IntroSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/MergeSortTest.php b/tests/Algorithm/Sort/MergeSortTest.php index 2c3363e4f..335980b94 100644 --- a/tests/Algorithm/Sort/MergeSortTest.php +++ b/tests/Algorithm/Sort/MergeSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Merge sort test + * @testdox phpOMS\tests\Algorithm\Sort\MergeSortTest: Merge sort * * @internal */ @@ -39,6 +39,9 @@ class MergeSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class MergeSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = MergeSort::sort($this->list); @@ -59,6 +65,9 @@ class MergeSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = MergeSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/OddEvenSortTest.php b/tests/Algorithm/Sort/OddEvenSortTest.php index ea817d006..90de4bf7d 100644 --- a/tests/Algorithm/Sort/OddEvenSortTest.php +++ b/tests/Algorithm/Sort/OddEvenSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: OddEven sort test + * @testdox phpOMS\tests\Algorithm\Sort\OddEvenSortTest: OddEven sort * * @internal */ @@ -39,6 +39,9 @@ class OddEvenSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class OddEvenSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = OddEvenSort::sort($this->list); @@ -59,6 +65,9 @@ class OddEvenSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = OddEvenSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/PancakeSortTest.php b/tests/Algorithm/Sort/PancakeSortTest.php index 4b01c643b..784593f5f 100644 --- a/tests/Algorithm/Sort/PancakeSortTest.php +++ b/tests/Algorithm/Sort/PancakeSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Pancake sort test + * @testdox phpOMS\tests\Algorithm\Sort\PancakeSortTest: Pancake sort * * @internal */ @@ -39,6 +39,9 @@ class PancakeSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class PancakeSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = PancakeSort::sort($this->list); @@ -59,6 +65,9 @@ class PancakeSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = PancakeSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/QuickSortTest.php b/tests/Algorithm/Sort/QuickSortTest.php index ba650c139..e6304176a 100644 --- a/tests/Algorithm/Sort/QuickSortTest.php +++ b/tests/Algorithm/Sort/QuickSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Quick sort test + * @testdox phpOMS\tests\Algorithm\Sort\QuickSortTest: Quick sort * * @internal */ @@ -39,6 +39,9 @@ class QuickSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class QuickSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = QuickSort::sort($this->list); @@ -59,6 +65,9 @@ class QuickSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = QuickSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/SelectionSortTest.php b/tests/Algorithm/Sort/SelectionSortTest.php index 8369b25a3..3e445f045 100644 --- a/tests/Algorithm/Sort/SelectionSortTest.php +++ b/tests/Algorithm/Sort/SelectionSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Selection sort test + * @testdox phpOMS\tests\Algorithm\Sort\SelectionSortTest: Selection sort * * @internal */ @@ -39,6 +39,9 @@ class SelectionSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class SelectionSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = SelectionSort::sort($this->list); @@ -59,6 +65,9 @@ class SelectionSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = SelectionSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/ShellSortTest.php b/tests/Algorithm/Sort/ShellSortTest.php index a2c209ff3..e4081752f 100644 --- a/tests/Algorithm/Sort/ShellSortTest.php +++ b/tests/Algorithm/Sort/ShellSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Shell sort test + * @testdox phpOMS\tests\Algorithm\Sort\ShellSortTest: Shell sort * * @internal */ @@ -39,6 +39,9 @@ class ShellSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class ShellSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = ShellSort::sort($this->list); @@ -59,6 +65,9 @@ class ShellSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = ShellSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/StoogeSortTest.php b/tests/Algorithm/Sort/StoogeSortTest.php index d32955eb3..bde8bcb8d 100644 --- a/tests/Algorithm/Sort/StoogeSortTest.php +++ b/tests/Algorithm/Sort/StoogeSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Stooge sort test + * @testdox phpOMS\tests\Algorithm\Sort\StoogeSortTest: Stooge sort * * @internal */ @@ -39,6 +39,9 @@ class StoogeSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class StoogeSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = StoogeSort::sort($this->list); @@ -59,6 +65,9 @@ class StoogeSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = StoogeSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Algorithm/Sort/TimSortTest.php b/tests/Algorithm/Sort/TimSortTest.php index e9d2e643a..e0205a9f5 100644 --- a/tests/Algorithm/Sort/TimSortTest.php +++ b/tests/Algorithm/Sort/TimSortTest.php @@ -20,7 +20,7 @@ use phpOMS\Algorithm\Sort\SortOrder; require_once __DIR__ . '/../../Autoloader.php'; /** - * @testdox phpOMS\tests\Algorithm\Sort: Tim sort test + * @testdox phpOMS\tests\Algorithm\Sort\TimSortTest: Tim sort * * @internal */ @@ -39,6 +39,9 @@ class TimSortTest extends \PHPUnit\Framework\TestCase ]; } + /** + * @testdox A list with one element returns the list with the element itself + */ public function testSmallList() : void { $smallList = [new NumericElement(3)]; @@ -47,6 +50,9 @@ class TimSortTest extends \PHPUnit\Framework\TestCase self::assertEquals($smallList, $newList); } + /** + * @testdox A list ot elements can be sorted in ASC order + */ public function testSortASC() : void { $newList = TimSort::sort($this->list); @@ -59,6 +65,9 @@ class TimSortTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox A list ot elements can be sorted in DESC order + */ public function testSortDESC() : void { $newList = TimSort::sort($this->list, SortOrder::DESC); diff --git a/tests/Business/Finance/DepreciationTest.php b/tests/Business/Finance/DepreciationTest.php index 51f182d9f..98444a829 100644 --- a/tests/Business/Finance/DepreciationTest.php +++ b/tests/Business/Finance/DepreciationTest.php @@ -17,7 +17,7 @@ namespace phpOMS\tests\Business\Finance; use phpOMS\Business\Finance\Depreciation; /** - * @testdox phpOMS\Business\Finance\DepreciationTest: Depreciation calculations + * @testdox phpOMS\tests\Business\Finance\DepreciationTest: Depreciation calculations * * @internal */ diff --git a/tests/Business/Finance/FinanceFormulasTest.php b/tests/Business/Finance/FinanceFormulasTest.php index d88a63dc5..127511e50 100644 --- a/tests/Business/Finance/FinanceFormulasTest.php +++ b/tests/Business/Finance/FinanceFormulasTest.php @@ -17,7 +17,7 @@ namespace phpOMS\tests\Business\Finance; use phpOMS\Business\Finance\FinanceFormulas; /** - * @testdox phpOMS\Business\Finance\FinanceFormulasTest: Finance formulas + * @testdox phpOMS\tests\Business\Finance\FinanceFormulasTest: Finance formulas * * @internal */ @@ -229,20 +229,33 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEquals(500 / 1000, FinanceFormulas::getDebtToIncomeRatio(500, 1000)); } + /** + * @testdox Return on balance statement positions are correct (e.g. return on assets, on equity) + */ + public function testReturnOnBalancePositions() : void + { + self::assertEquals(500 / 1000, FinanceFormulas::getReturnOnAssets(500, 1000)); + self::assertEquals(500 / 1000, FinanceFormulas::getReturnOnEquity(500, 1000)); + self::assertEquals(500 / 1000 - 1, FinanceFormulas::getReturnOnInvestment(500, 1000)); + } + + /** + * @testdox Balance / P&L ratios are correct (e.g. inventory turnover, net profit margin) + */ + public function testBalancePLRatios() : void + { + self::assertEquals(500 / 1000, FinanceFormulas::getInventoryTurnoverRatio(500, 1000)); + self::assertEquals(500 / 1000, FinanceFormulas::getNetProfitMargin(500, 1000)); + self::assertEquals(500 / 1000, FinanceFormulas::getReceivablesTurnoverRatio(500, 1000)); + } + public function testRatios() : void { self::assertEquals(500 / 1000, FinanceFormulas::getInterestCoverageRatio(500, 1000)); - self::assertEquals(500 / 1000, FinanceFormulas::getInventoryTurnoverRatio(500, 1000)); - self::assertEquals(500 / 1000, FinanceFormulas::getNetProfitMargin(500, 1000)); - - self::assertEquals(500 / 1000, FinanceFormulas::getReturnOnAssets(500, 1000)); - self::assertEquals(500 / 1000, FinanceFormulas::getReturnOnEquity(500, 1000)); - self::assertEquals(500 / 1000, FinanceFormulas::getReceivablesTurnoverRatio(500, 1000)); self::assertEquals(500 / 1000, FinanceFormulas::getQuickRatio(500, 1000)); - self::assertEquals(500 / 1000 - 1, FinanceFormulas::getReturnOnInvestment(500, 1000)); self::assertEquals((500 - 300) / 500, FinanceFormulas::getRetentionRatio(500, 300)); - self::assertEquals(500 / 1000 - 1, FinanceFormulas::getRateOfOnflation(500, 1000)); + self::assertEquals(500 / 1000 - 1, FinanceFormulas::getRateOfInflation(500, 1000)); self::assertEquals(1000 / 500, FinanceFormulas::getPaybackPeriod(1000, 500)); self::assertEquals(100 / 0.15, FinanceFormulas::getPresentValueOfPerpetuity(100, 0.15)); @@ -336,6 +349,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta($r, FinanceFormulas::getDoublingContinuousCompoundingRate(13.863), 0.01); } + /** + * @testdox Calculations for equivalent annual annuity are correct + */ public function testEquivalentAnnualAnnuity() : void { $npv = 1000; @@ -347,6 +363,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta($npv, FinanceFormulas::getNetPresentValueOfEAA(240.36, $r, $n), 0.01); } + /** + * @testdox The free cash flow to equity calculation is correct (how much cash is available after expenses and dept payments) + */ public function testFreeCashFlowToEquity() : void { $income = 1000; @@ -358,6 +377,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(1200, FinanceFormulas::getFreeCashFlowToEquity($income, $depamo, $capital, $wc, $borrowing), 0.01); } + /** + * @testdox The free cash flow to firm calculation is correct (how much cash is available after expenses) + */ public function testFreeCashFlowToFirm() : void { $ebit = 1000; @@ -369,6 +391,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(550, FinanceFormulas::getFreeCashFlowToFirm($ebit, $t, $depamo, $capital, $wc), 0.01); } + /** + * @testdox The future value calculation is correct + */ public function testFutureValue() : void { $c = 1000; @@ -378,6 +403,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(2660.02, FinanceFormulas::getFutureValue($c, $r, $n), 0.01); } + /** + * @testdox The future value calculation including continuous compounding is correct + */ public function testFutureValueContinuousCompounding() : void { $pv = 1000; @@ -387,6 +415,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(2857.65, FinanceFormulas::getFutureValueContinuousCompounding($pv, $r, $t), 0.01); } + /** + * @testdox The future value factor calculation is correct + */ public function testValueFactor() : void { $r = 0.15; @@ -396,6 +427,9 @@ class FinanceFormulasTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(0.37594, FinanceFormulas::getPresentValueFactor($r, $n), 0.01); } + /** + * @testdox The calculation of the geometric mean of multiple return rates is correct + */ public function testGeometricMeanReturn() : void { $r = [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07]; diff --git a/tests/Business/Finance/LoanTest.php b/tests/Business/Finance/LoanTest.php index 70a0b4a78..c0b5e468d 100644 --- a/tests/Business/Finance/LoanTest.php +++ b/tests/Business/Finance/LoanTest.php @@ -17,16 +17,31 @@ namespace phpOMS\tests\Business\Finance; use phpOMS\Business\Finance\Loan; /** + * @testdox phpOMS\tests\Business\Finance\LoanTest: Loan formulas + * * @internal */ class LoanTest extends \PHPUnit\Framework\TestCase { - public function testRatios() : void + /** + * @testdox The loan to deposit ratio is correct + */ + public function testLoanToDepositRatio() : void { self::assertEquals(100 / 50, Loan::getLoanToDepositRatio(100, 50)); + } + + /** + * @testdox The loan to value ratio is correct + */ + public function testLoanToValueRatio() : void + { self::assertEquals(100 / 50, Loan::getLoanToValueRatio(100, 50)); } + /** + * @testdox The balloon loan payments are correct for a given balloon + */ public function testPaymentsOnBalloonLoan() : void { $pv = 1000; @@ -37,6 +52,9 @@ class LoanTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(213.25, Loan::getPaymentsOnBalloonLoan($pv, $r, $n, $balloon), 0.01); } + /** + * @testdox The balloon loan residual value (balloon) is correct for given payments + */ public function testBalloonBalanceOfLoan() : void { $pv = 1000; @@ -47,6 +65,9 @@ class LoanTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(-660.02, Loan::getBalloonBalanceOfLoan($pv, $p, $r, $n), 0.01); } + /** + * @testdox The loan payments are correct for a given interest rate and period [continuous compounding] + */ public function testLoanPayment() : void { $pv = 1000; @@ -56,6 +77,9 @@ class LoanTest extends \PHPUnit\Framework\TestCase self::assertEqualsWithDelta(240.36, Loan::getLoanPayment($pv, $r, $n), 0.01); } + /** + * @testdox The residual value is correct for a given payment amount, interest rate and period [continuous compounding] + */ public function testRemainingBalanceLoan() : void { $pv = 1000; diff --git a/tests/Business/Finance/LorenzkurveTest.php b/tests/Business/Finance/LorenzkurveTest.php index 506ae3af3..c70aec983 100644 --- a/tests/Business/Finance/LorenzkurveTest.php +++ b/tests/Business/Finance/LorenzkurveTest.php @@ -17,14 +17,19 @@ namespace phpOMS\tests\Business\Finance; use phpOMS\Business\Finance\Lorenzkurve; /** + * @testdox phpOMS\tests\Business\Finance\LorenzkurveTest: Lorenz kurve + * * @internal */ class LorenzkurveTest extends \PHPUnit\Framework\TestCase { - public function testLorenz() : void + /** + * @testdox The gini coefficient calculation is correct + */ + public function testGiniCoefficient() : void { $arr = [1, 1, 1, 1, 1, 1, 1, 10, 33, 50]; - self::assertTrue(\abs(0.71 - LorenzKurve::getGiniCoefficient($arr)) < 0.01); + self::assertEqualsWithDelta(0.71, LorenzKurve::getGiniCoefficient($arr), 0.01); } } diff --git a/tests/Business/Marketing/MetricsTest.php b/tests/Business/Marketing/MetricsTest.php index 88cb1e8e1..ddbe9087b 100644 --- a/tests/Business/Marketing/MetricsTest.php +++ b/tests/Business/Marketing/MetricsTest.php @@ -28,6 +28,6 @@ class MetricsTest extends \PHPUnit\Framework\TestCase */ public function testCustomerRetention() : void { - self::assertTrue(0.85 - Metrics::getCustomerRetention(105, 20, 100) < 0.01); + self::assertEqualsWithDelta(0.85, Metrics::getCustomerRetention(105, 20, 100), 0.01); } } diff --git a/tests/Business/Marketing/NetPromoterScoreTest.php b/tests/Business/Marketing/NetPromoterScoreTest.php index 35ccceab1..badf16840 100644 --- a/tests/Business/Marketing/NetPromoterScoreTest.php +++ b/tests/Business/Marketing/NetPromoterScoreTest.php @@ -24,7 +24,7 @@ use phpOMS\Business\Marketing\NetPromoterScore; class NetPromoterScoreTest extends \PHPUnit\Framework\TestCase { /** - * @testdox The default net promoter score is 0 + * @testdox The net promoter has the expected default values after initialization */ public function testDefault() : void { diff --git a/tests/Business/Sales/MarketShareEstimationTest.php b/tests/Business/Sales/MarketShareEstimationTest.php index db23a1ade..e5667856d 100644 --- a/tests/Business/Sales/MarketShareEstimationTest.php +++ b/tests/Business/Sales/MarketShareEstimationTest.php @@ -17,6 +17,7 @@ use phpOMS\Business\Sales\MarketShareEstimation; /** * @testdox phpOMS\tests\Business\Sales\MarketShareEstimationTest: Market share calculations + * * @internal */ class MarketShareEstimationTest extends \PHPUnit\Framework\TestCase diff --git a/tests/Config/OptionsTraitTest.php b/tests/Config/OptionsTraitTest.php index b8565d6cd..466dad93b 100644 --- a/tests/Config/OptionsTraitTest.php +++ b/tests/Config/OptionsTraitTest.php @@ -19,12 +19,17 @@ use phpOMS\Config\OptionsTrait; require_once __DIR__ . '/../Autoloader.php'; /** + * @testdox phpOMS\tests\Config\OptionsTrait: Helper for managing otpions + * * @internal */ class OptionsTraitTest extends \PHPUnit\Framework\TestCase { - public function testOptionTrait() : void + /** + * @testdox The option helper has the expected attributes + */ + public function testOptionTraitMembers() : void { $class = new class() { use OptionsTrait; @@ -34,6 +39,9 @@ class OptionsTraitTest extends \PHPUnit\Framework\TestCase self::assertObjectHasAttribute('options', $class); } + /** + * @testdox The option helper has the expected default values after initialization + */ public function testDefault() : void { $class = new class() { @@ -44,7 +52,24 @@ class OptionsTraitTest extends \PHPUnit\Framework\TestCase self::assertNull($class->getOption('someKey')); } - public function testSetGet() : void + /** + * @testdox Options can be added to the helper + */ + public function testAdd() : void + { + $class = new class() { + use OptionsTrait; + }; + + self::assertTrue($class->setOption('a', 'value1')); + self::assertTrue($class->exists('a')); + self::assertEquals('value1', $class->getOption('a')); + } + + /** + * @testdox Options can be overwritten/changed + */ + public function testOverwrite() : void { $class = new class() { use OptionsTrait; @@ -65,12 +90,27 @@ class OptionsTraitTest extends \PHPUnit\Framework\TestCase self::assertFalse($class->setOption('a', 'value4', false)); self::assertTrue($class->exists('a')); self::assertEquals('value3', $class->getOption('a')); + } + + /** + * @testdox Multiple options can be added to the helper in one go + */ + public function testAddMultiple() : void + { + $class = new class() { + use OptionsTrait; + }; + + self::assertTrue($class->setOption('a', 'value3', true)); + self::assertTrue($class->exists('a')); + self::assertEquals('value3', $class->getOption('a')); self::assertTrue($class->setOptions(['b' => 2, 'c' => '3'], true)); self::assertTrue($class->setOptions(['b' => 4, 'c' => '5'], false)); // always returns true self::assertTrue($class->exists('a')); self::assertTrue($class->exists('b')); self::assertTrue($class->exists('c')); + self::assertEquals('value3', $class->getOption('a')); self::assertEquals(2, $class->getOption('b')); self::assertEquals(3, $class->getOption('c')); diff --git a/tests/DataStorage/Cache/CachePoolTest.php b/tests/DataStorage/Cache/CachePoolTest.php index 66675a63a..1ef50fc0a 100644 --- a/tests/DataStorage/Cache/CachePoolTest.php +++ b/tests/DataStorage/Cache/CachePoolTest.php @@ -18,10 +18,15 @@ use phpOMS\DataStorage\Cache\CachePool; use phpOMS\DataStorage\Cache\Connection\FileCache; /** + * @testdox phpOMS\tests\DataStorage\Cache\CachePoolTest: Pool for caches + * * @internal */ class CachePoolTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The pool has the expected default values after initialization + */ public function testDefault() : void { $pool = new CachePool(); @@ -30,20 +35,84 @@ class CachePoolTest extends \PHPUnit\Framework\TestCase self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\NullCache', $pool->get()); } - public function testGetSet() : void + /** + * @testdox New cache connections can be added to the pool + */ + public function testAdd() : void + { + $pool = new CachePool(); + + self::assertTrue($pool->add('test', new FileCache(__DIR__))); + } + + /** + * @testdox Cache connections cannot be overwritten with a different cache connection + */ + public function testOverwrite() : void { $pool = new CachePool(); self::assertTrue($pool->add('test', new FileCache(__DIR__))); self::assertFalse($pool->add('test', new FileCache(__DIR__))); + } + + /** + * @testdox Cache connections can be accessed with an identifier + */ + public function testGet() : void + { + $pool = new CachePool(); + + self::assertTrue($pool->add('test', new FileCache(__DIR__))); self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\ConnectionInterface', $pool->get('test')); self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\ConnectionInterface', $pool->get()); + } + + /** + * @testdox By default a null cache is returned if no cache connection exists for the identifier + */ + public function testGetDefault() : void + { + $pool = new CachePool(); + + self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\NullCache', $pool->get('abc')); + } + + /** + * @testdox Cache connections can created by the pool and automatically get added but not overwritten + */ + public function testCreate() : void + { + $pool = new CachePool(); + self::assertTrue($pool->create('abc', ['type' => 'file', 'path' => __DIR__])); self::assertFalse($pool->create('abc', ['type' => 'file', 'path' => __DIR__])); self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\ConnectionInterface', $pool->get('abc')); + } + + /** + * @testdox Cache connections can be removed from the pool + */ + public function testRemove() : void + { + $pool = new CachePool(); + + self::assertTrue($pool->add('test', new FileCache(__DIR__))); + self::assertTrue($pool->create('abc', ['type' => 'file', 'path' => __DIR__])); self::assertTrue($pool->remove('abc')); self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\NullCache', $pool->get('abc')); self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\ConnectionInterface', $pool->get('test')); + } + + /** + * @testdox Removing a cache with an invalid identifier will result in no actions + */ + public function testRemoveInvalid() : void + { + $pool = new CachePool(); + + self::assertTrue($pool->add('test', new FileCache(__DIR__))); self::assertFalse($pool->remove('abc')); + self::assertInstanceOf('\phpOMS\DataStorage\Cache\Connection\ConnectionInterface', $pool->get('test')); } } diff --git a/tests/DataStorage/Cache/Connection/ConnectionFactoryTest.php b/tests/DataStorage/Cache/Connection/ConnectionFactoryTest.php index 390373f1c..dbebb3d13 100644 --- a/tests/DataStorage/Cache/Connection/ConnectionFactoryTest.php +++ b/tests/DataStorage/Cache/Connection/ConnectionFactoryTest.php @@ -18,10 +18,15 @@ use phpOMS\DataStorage\Cache\CacheType; use phpOMS\DataStorage\Cache\Connection\ConnectionFactory; /** + * @testdox phpOMS\tests\DataStorage\Cache\Connection\ConnectionFactoryTest: Factory for generating cache connections + * * @internal */ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The file cache can be created + */ public function testCreateFileCache() : void { self::assertInstanceOf( @@ -30,6 +35,9 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox The memcached cache can be created + */ public function testCreateMemCached() : void { if (!\extension_loaded('memcached')) { @@ -44,6 +52,9 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox The redis cache can be created + */ public function testCreateRedisCache() : void { if (!\extension_loaded('redis')) { @@ -58,6 +69,9 @@ class ConnectionFactoryTest extends \PHPUnit\Framework\TestCase ); } + /** + * @testdox An invalid cache type results in an exception + */ public function testInvalidCacheType() : void { self::expectException(\InvalidArgumentException::class); diff --git a/tests/DataStorage/Cache/Connection/FileCacheTest.php b/tests/DataStorage/Cache/Connection/FileCacheTest.php index 41ba53391..ab8b20800 100644 --- a/tests/DataStorage/Cache/Connection/FileCacheTest.php +++ b/tests/DataStorage/Cache/Connection/FileCacheTest.php @@ -20,10 +20,15 @@ use phpOMS\DataStorage\Cache\Connection\FileCache; use phpOMS\Utils\TestUtils; /** + * @testdox phpOMS\tests\DataStorage\Cache\Connection\FileCacheTest: File cache connection + * * @internal */ class FileCacheTest extends \PHPUnit\Framework\TestCase { + /** + * @testdox The file cache connection has the expected default values after initialization + */ public function testDefault() : void { if (\file_exists(__DIR__ . '/Cache')) { @@ -44,6 +49,9 @@ class FileCacheTest extends \PHPUnit\Framework\TestCase } } + /** + * @testdox The connection to a dedicated cache directory can be established (none-exising directories get created) + */ public function testConnect() : void { if (\file_exists(__DIR__ . '/Cache')) {