RaindropsTest.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /*
  3. * By adding type hints and enabling strict type checking, code can become
  4. * easier to read, self-documenting and reduce the number of potential bugs.
  5. * By default, type declarations are non-strict, which means they will attempt
  6. * to change the original type to match the type specified by the
  7. * type-declaration.
  8. *
  9. * In other words, if you pass a string to a function requiring a float,
  10. * it will attempt to convert the string value to a float.
  11. *
  12. * To enable strict mode, a single declare directive must be placed at the top
  13. * of the file.
  14. * This means that the strictness of typing is configured on a per-file basis.
  15. * This directive not only affects the type declarations of parameters, but also
  16. * a function's return type.
  17. *
  18. * For more info review the Concept on strict type checking in the PHP track
  19. * <link>.
  20. *
  21. * To disable strict typing, comment out the directive below.
  22. */
  23. declare(strict_types=1);
  24. class RaindropsTest extends PHPUnit\Framework\TestCase
  25. {
  26. public static function setUpBeforeClass(): void
  27. {
  28. require_once 'Raindrops.php';
  29. }
  30. public function test1(): void
  31. {
  32. $this->assertSame("1", raindrops(1));
  33. }
  34. public function test3(): void
  35. {
  36. $this->assertSame("Pling", raindrops(3));
  37. }
  38. public function test5(): void
  39. {
  40. $this->assertSame("Plang", raindrops(5));
  41. }
  42. public function test7(): void
  43. {
  44. $this->assertSame("Plong", raindrops(7));
  45. }
  46. public function test6(): void
  47. {
  48. $this->assertSame("Pling", raindrops(6));
  49. }
  50. public function test9(): void
  51. {
  52. $this->assertSame("Pling", raindrops(9));
  53. }
  54. public function test10(): void
  55. {
  56. $this->assertSame("Plang", raindrops(10));
  57. }
  58. public function test14(): void
  59. {
  60. $this->assertSame("Plong", raindrops(14));
  61. }
  62. public function test15(): void
  63. {
  64. $this->assertSame("PlingPlang", raindrops(15));
  65. }
  66. public function test21(): void
  67. {
  68. $this->assertSame("PlingPlong", raindrops(21));
  69. }
  70. public function test25(): void
  71. {
  72. $this->assertSame("Plang", raindrops(25));
  73. }
  74. public function test35(): void
  75. {
  76. $this->assertSame("PlangPlong", raindrops(35));
  77. }
  78. public function test49(): void
  79. {
  80. $this->assertSame("Plong", raindrops(49));
  81. }
  82. public function test52(): void
  83. {
  84. $this->assertSame("52", raindrops(52));
  85. }
  86. public function test105(): void
  87. {
  88. $this->assertSame("PlingPlangPlong", raindrops(105));
  89. }
  90. public function test12121(): void
  91. {
  92. $this->assertSame("12121", raindrops(12121));
  93. }
  94. }