Skip to content

Commit

Permalink
Update unit test for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
JBlond committed Feb 14, 2024
1 parent 6dc74a9 commit a9b829f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
/.phpunit.result.cache
/composer.lock
/html
/vendor
2 changes: 1 addition & 1 deletion src/Fibonacci.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function fibonacciRecursion(int $number): array
* @param int $number
* @return int
*/
protected function recursion(int $number): int
public function recursion(int $number): int
{
if ($number < 0) {
throw new ValueError('Number must be greater than 0.');
Expand Down
39 changes: 39 additions & 0 deletions tests/math/FibonacciTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,45 @@ public function testFibonacciRecursion(): void
],
$this->fibonacci->fibonacciRecursion(7)
);
$this->assertEquals(
[],
$this->fibonacci->fibonacciRecursion(-2)
);
}

/**
* @return void
*/
public function testRecursion(): void
{
$this->assertEquals(
5,
$this->fibonacci->recursion(5)
);
}

/**
* @return void
*/
public function testRecursionException(): void
{
$this->expectException(\ValueError::class);
$this->assertEquals(
5,
$this->fibonacci->recursion(-2)
);
}

/**
* @return void
*/
public function testFibonacciWithBinetFormulaException(): void
{
$this->expectException(\ValueError::class);
$this->assertEquals(
[],
$this->fibonacci->fibonacciWithBinetFormula(-2)
);
}

/**
Expand Down

0 comments on commit a9b829f

Please sign in to comment.