forked from carlosbuenosvinos/php-kata
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modernization. phpunit 9, package upgrades, newer php syntax and feat…
…ures
- Loading branch information
Showing
6 changed files
with
33 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
composer.lock | ||
composer.phar | ||
/vendor/ | ||
/vendor/ | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
<?php | ||
|
||
namespace Kata; | ||
|
||
/** | ||
* Class Adder | ||
* @package Kata | ||
*/ | ||
class Adder | ||
{ | ||
/** | ||
* @param int $first | ||
* @param int $second | ||
* @return int | ||
*/ | ||
public function add($first, $second) | ||
public function add(?int $first, ?int $second): int | ||
{ | ||
return (int) $first + (int) $second; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
<?php | ||
|
||
namespace Kata\Tests; | ||
|
||
use Kata\Adder; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AdderTest extends \PHPUnit_Framework_TestCase | ||
class AdderTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* @dataProvider validSumsProvider | ||
* @param int $a | ||
* @param int $b | ||
* @param $expectedResult | ||
*/ | ||
public function validSums($a, $b, $expectedResult) | ||
public function testValidSums(?int $a, ?int $b, int $expectedResult): void | ||
{ | ||
$this->assertEquals( | ||
$expectedResult, | ||
(new Adder())->add($a, $b) | ||
); | ||
} | ||
|
||
public function validSumsProvider() | ||
public function validSumsProvider(): array | ||
{ | ||
return [ | ||
[null, null, 0], | ||
[0, 0, 0], | ||
[1, 1, 2] | ||
]; | ||
} | ||
} | ||
} |