|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * By adding type hints and enabling strict type checking, code can become |
| 5 | + * easier to read, self-documenting and reduce the number of potential bugs. |
| 6 | + * By default, type declarations are non-strict, which means they will attempt |
| 7 | + * to change the original type to match the type specified by the |
| 8 | + * type-declaration. |
| 9 | + * |
| 10 | + * In other words, if you pass a string to a function requiring a float, |
| 11 | + * it will attempt to convert the string value to a float. |
| 12 | + * |
| 13 | + * To enable strict mode, a single declare directive must be placed at the top |
| 14 | + * of the file. |
| 15 | + * This means that the strictness of typing is configured on a per-file basis. |
| 16 | + * This directive not only affects the type declarations of parameters, but also |
| 17 | + * a function's return type. |
| 18 | + * |
| 19 | + * For more info review the Concept on strict type checking in the PHP track |
| 20 | + * <link>. |
| 21 | + * |
| 22 | + * To disable strict typing, comment out the directive below. |
| 23 | + */ |
| 24 | + |
| 25 | +declare(strict_types=1); |
| 26 | + |
| 27 | +class EliudsEggsTest extends PHPUnit\Framework\TestCase |
| 28 | +{ |
| 29 | + public static function setUpBeforeClass(): void |
| 30 | + { |
| 31 | + require_once 'EliudsEggs.php'; |
| 32 | + } |
| 33 | + |
| 34 | + /** |
| 35 | + * @testdox 0 eggs |
| 36 | + */ |
| 37 | + public function test0Eggs() |
| 38 | + { |
| 39 | + $eliudsEggs = new EliudsEggs(); |
| 40 | + $this->assertEquals(0, $eliudsEggs->eggCount(0)); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * @testdox 1 eggs |
| 45 | + */ |
| 46 | + public function test1Eggs() |
| 47 | + { |
| 48 | + $eliudsEggs = new EliudsEggs(); |
| 49 | + $this->assertEquals(1, $eliudsEggs->eggCount(16)); |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * @testdox 4 eggs |
| 54 | + */ |
| 55 | + public function test4Eggs() |
| 56 | + { |
| 57 | + $eliudsEggs = new EliudsEggs(); |
| 58 | + $this->assertEquals(4, $eliudsEggs->eggCount(89)); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * @testdox 13 eggs |
| 63 | + */ |
| 64 | + public function test13Eggs() |
| 65 | + { |
| 66 | + $eliudsEggs = new EliudsEggs(); |
| 67 | + $this->assertEquals(13, $eliudsEggs->eggCount(2000000000)); |
| 68 | + } |
| 69 | +} |
0 commit comments