{"id":1126,"date":"2025-01-28T18:34:07","date_gmt":"2025-01-28T09:34:07","guid":{"rendered":"https:\/\/race-ss.co.jp\/blog\/?p=1126"},"modified":"2025-12-17T19:27:29","modified_gmt":"2025-12-17T10:27:29","slug":"%e3%80%90%e3%83%86%e3%82%b9%e3%83%88%e5%88%9d%e5%bf%83%e8%80%85%e5%90%91%e3%81%91%e3%80%91tdd%e5%ae%9f%e8%b7%b5%e6%bc%94%e7%bf%92%ef%bd%9ephpunit%e3%82%92%e4%bd%bf%e3%81%a3%e3%81%a6fizzbuzz%e5%95%8f","status":"publish","type":"post","link":"https:\/\/race-ss.co.jp\/blog\/?p=1126","title":{"rendered":"\u3010\u30c6\u30b9\u30c8\u521d\u5fc3\u8005\u5411\u3051\u3011TDD\u5b9f\u8df5\u6f14\u7fd2\uff5ePHPUnit\u3092\u4f7f\u3063\u3066FizzBuzz\u554f\u984c\u3092\u5b9f\u88c5\u3057\u3066\u307f\u305f\uff5e"},"content":{"rendered":"\n<p>\u3053\u3093\u306b\u3061\u306f\uff01RSS\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306eK.A.\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4eca\u56de\u306f\u3001\u30c6\u30b9\u30c8\u521d\u5fc3\u8005\u5411\u3051\u306e\u30c6\u30fc\u30de\u3068\u3057\u3066\u3001\u300cPHPUnit\u3092\u4f7f\u3063\u305fFizzBuzz\u554f\u984c\u5b9f\u88c5\u300d\u306b\u3064\u3044\u3066\u304a\u8a71\u3057\u3057\u307e\u3059\uff01<br>\u3053\u306e\u30c6\u30fc\u30de\u306e\u8a18\u4e8b\u3092\u66f8\u3053\u3046\u3068\u601d\u3063\u305f\u80cc\u666f\u3068\u3057\u3066\u306f\u3001\u521d\u3081\u3066\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u306b\u53d6\u308a\u7d44\u3080\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306b\u53c2\u52a0\u3059\u308b\u6a5f\u4f1a\u304c\u3042\u308a\u3001\u305d\u306e\u4f53\u9a13\u8ac7\u3092\u66f8\u304d\u8a18\u305d\u3046\u3068\u601d\u3063\u305f\u304b\u3089\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u307e\u3067\u306e\u958b\u767a\u7d4c\u9a13\u3067\u306f\u3001\u5b9f\u88c5\u30b3\u30fc\u30c9\u306b\u91cd\u70b9\u3092\u7f6e\u304f\u3053\u3068\u304c\u591a\u304b\u3063\u305f\u3067\u3059\u304c\u3001TDD\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u5b66\u3076\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u54c1\u8cea\u5411\u4e0a\u3084\u30d0\u30b0\u306e\u65e9\u671f\u767a\u898b\u306b\u5bfe\u3059\u308b\u610f\u8b58\u304c\u9ad8\u307e\u308a\u307e\u3057\u305f\u3002<br>\u307e\u305a\u306f\u3001\u8a18\u4e8b\u306e\u30bf\u30a4\u30c8\u30eb\u306b\u3064\u3044\u3066\u7c21\u5358\u306b\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">PHPUnit\u3068\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u306e\u95a2\u4fc2<\/h1>\n\n\n\n<p>PHPUnit\u306f\u3001PHP\u7528\u306e\u30c6\u30b9\u30c8\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u3042\u308a\u3001\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u3092\u5b9f\u8df5\u3059\u308b\u969b\u306b\u975e\u5e38\u306b\u6709\u7528\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002TDD\u306e\u30d7\u30ed\u30bb\u30b9\u3067\u306f\u3001\u958b\u767a\u8005\u306f\u307e\u305a\u30c6\u30b9\u30c8\u9805\u76ee\u3092\u4f5c\u6210\u3057\u3001\u305d\u306e\u5f8c\u306b\u671f\u5f85\u3055\u308c\u308b\u6a5f\u80fd\u3092\u6301\u3064\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3057\u307e\u3059\u3002PHPUnit\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30c6\u30b9\u30c8\u306e\u4f5c\u6210\u3001\u5b9f\u884c\u3001\u7d50\u679c\u306e\u78ba\u8a8d\u304c\u5bb9\u6613\u306b\u306a\u308a\u3001\u8fc5\u901f\u306a\u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af\u304c\u5f97\u3089\u308c\u307e\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u958b\u767a\u8005\u306f\u4ed5\u69d8\u306b\u6cbf\u3063\u305f\u9ad8\u54c1\u8cea\u306a\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u52b9\u7387\u7684\u306b\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u30c6\u30b9\u30c8\u99c6\u52d5\u958b\u767a\uff08TDD\uff09\u3068\u306f<\/h1>\n\n\n\n<p>\u300c\u30c6\u30b9\u30c8(RED)\u2192\u5b9f\u88c5(GREEN)\u2192\u30ea\u30d5\u30a1\u30af\u30bf(REFACTOR)\u300d\u3068\u3044\u3046\u30b5\u30a4\u30af\u30eb\u3092\u7e70\u308a\u8fd4\u3057\u306a\u304c\u3089\u3001\u30d7\u30ed\u30c0\u30af\u30c8\u306e\u54c1\u8cea\u3092\u5411\u4e0a\u3055\u305b\u3066\u3044\u304f\u958b\u767a\u624b\u6cd5\u3067\u3059\u3002\u30c6\u30b9\u30c8\u9805\u76ee\u306f\u5c0f\u3055\u3044\u5358\u4f4d\u3067\u4f5c\u6210\u3059\u308b\u3053\u3068\u304c\u63a8\u5968\u3055\u308c\u3066\u3044\u3066\u3001\u3053\u308c\u306b\u3088\u308a\u9ad8\u54c1\u8cea\u306a\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3092\u52b9\u7387\u7684\u306b\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf_OstJTXrKwPweSdKCXUGmnFfYij7KuBbunPM-pmxW_PEqYbCvis4ZvPhJ2dCV4qQ4nD99oUSPoRgkjxUKnEl1pGA4jSY0glqVvPnaGE-eCsM4kQaUCXeA9rZgSgl_4WEqXCvQbw?key=VL215w2CC1vcOjHt50LOfZEy\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>~\u30e1\u30ea\u30c3\u30c8\u3068\u30c7\u30e1\u30ea\u30c3\u30c8~<\/strong><\/p>\n\n\n\n<p><strong>[\u30e1\u30ea\u30c3\u30c8]<\/strong><\/p>\n\n\n\n<p>\u30fb\u6539\u4fee\u306e\u305f\u3073\u306b\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u3053\u3068\u3067\u5f71\u97ff\u3059\u308b\u7b87\u6240\u3067\u30a8\u30e9\u30fc\u3092\u691c\u77e5\u3067\u304d\u308b\u305f\u3081\u3001\u5b89\u5fc3\u3057\u3066\u4fee\u6b63\u304c\u3067\u304d\u308b<br>\u30fb\u30c6\u30b9\u30c8\u306f\u30b3\u30fc\u30c9\u306e\u4ed5\u69d8\u3084\u52d5\u4f5c\u3092\u53ef\u8996\u5316\u3059\u308b\u305f\u3081\u3001\u4ed5\u69d8\u304c\u308f\u304b\u308a\u3084\u3059\u304f\u306a\u308b<br>\u30fb\u30c6\u30b9\u30c8\u9805\u76ee\u3092\u5148\u306b\u66f8\u304f\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u8a2d\u8a08\u6bb5\u968e\u3067\u554f\u984c\u3092\u767a\u898b\u3057\u3084\u3059\u3044<br>\u30fb\u30c6\u30b9\u30c8\u3067\u671f\u5f85\u901a\u308a\u306e\u52d5\u4f5c\u3092\u4fdd\u6301\u3067\u304d\u308b\u3053\u3068\u304b\u3089\u3001\u30ea\u30ea\u30fc\u30b9\u5f8c\u306e\u4e0d\u5177\u5408\u3092\u6e1b\u5c11\u3055\u305b\u3001\u4fe1\u983c\u6027\u304c\u9ad8\u307e\u308b<\/p>\n\n\n\n<p><strong>[\u30c7\u30e1\u30ea\u30c3\u30c8]<\/strong><\/p>\n\n\n\n<p>\u30fbTDD\u306e\u624b\u6cd5\u3092\u7406\u89e3\u3057\u5b9f\u8df5\u3059\u308b\u305f\u3081\u306e\u521d\u671f\u6295\u8cc7\u304c\u5fc5\u8981<br>\u30fb\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3068\u30b3\u30fc\u30c9\u91cf\u304c\u5927\u304d\u304f\u306a\u308a\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u3092\u884c\u3046\u969b\u3082\u4fee\u6b63\u91cf\u304c\u591a\u304f\u8ca0\u62c5\u304c\u304b\u304b\u308b<\/p>\n\n\n\n<p><strong>~TDD\u306e\u6d41\u308c~<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u9805\u76ee\u3092\u66f8\u304d\u51fa\u3059<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\uff08\u72b6\u614b\uff1aRED\uff09<\/li>\n\n\n\n<li>\u30c6\u30b9\u30c8\u304c\u6210\u529f\u3059\u308b\u3088\u3046\u306a\u5b9f\u88c5\u30b3\u30fc\u30c9\u3092\u66f8\u304f\uff08\u72b6\u614b\uff1aGREEN\uff09<\/li>\n\n\n\n<li>\u5b9f\u88c5\u30b3\u30fc\u30c9\u304c\u5b8c\u6210\u3057\u305f\u3089\u4f59\u5206\u306a\u30b3\u30fc\u30c9\u3092\u6d88\u3057\u3066\u3088\u308a\u52b9\u7387\u7684\u306a\u5f62\u306b\u6574\u5f62\u3059\u308b\uff08\u72b6\u614b\uff1aREFACTOR\uff09<\/li>\n\n\n\n<li>3~5\u306e\u7e70\u308a\u8fd4\u3057<\/li>\n\n\n\n<li>3\u3067\u66f8\u304d\u51fa\u3057\u305f\u30c6\u30b9\u30c8\u9805\u76ee\u3059\u3079\u3066\u304c\u5b8c\u4e86\u3057\u305f\u3089\u5b8c\u6210<\/li>\n<\/ol>\n\n\n\n<h1 class=\"wp-block-heading\">FizzBuzz\u3068\u306f<\/h1>\n\n\n\n<p>\u4eca\u56de\u306e\u30c6\u30fc\u30de\u306b\u3082\u3042\u308bFizzBuzz\u306b\u3064\u3044\u3066\u7c21\u5358\u306b\u8aac\u660e\u3057\u307e\u3059\u3002<br>FizzBuzz\u3068\u306f\u3082\u3068\u306f\u7c21\u5358\u306a\u30d1\u30fc\u30c6\u30a3\u30fc\u30b2\u30fc\u30e0\u3067\u3001\u3088\u304f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u554f\u984c\u3068\u3057\u3066\u51fa\u984c\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u2013 1\u304b\u3089100\u307e\u3067\u306e\u6570\u5b57\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b<br>\u2013 3\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306f\u6570\u5b57\u306e\u4ee3\u308f\u308a\u306b\u300cFizz\u300d\u3068\u8868\u793a<br>\u2013 5\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306f\u6570\u5b57\u306e\u4ee3\u308f\u308a\u306b\u300cBuzz\u300d\u3068\u8868\u793a<br>\u2013 15\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306f\u6570\u5b57\u306e\u4ee3\u308f\u308a\u306b\u300cFizzBuzz\u300d\u3068\u8868\u793a<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">TDD\u5b9f\u8df5<\/h1>\n\n\n\n<p>\u5b9f\u969b\u306bTDD\u3092\u5b9f\u8df5\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p><strong>1.\u6e96\u5099<\/strong><\/p>\n\n\n\n<p>[\u4eca\u56de\u4f7f\u7528\u3059\u308b\u74b0\u5883]<\/p>\n\n\n\n<p>\u30fbphp 8.3<br>\u30fbPHPUnit 11<br>\u30fblaravel 11<\/p>\n\n\n\n<p>[\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u6210]<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>project\/\n\u251c\u2500\u2500 app\/FizzBuzz.php\n\u251c\u2500\u2500 tests\/Feature\/FizzBuzzTest.php<\/code><\/pre>\n\n\n\n<p>[Docker\u30d5\u30a1\u30a4\u30eb]<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM php:8.3-apache\n\n# apache\u306econf\nADD \/apache2\/sites-available\/000-default.conf \/etc\/apache2\/sites-available\/\n\n# composer\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nCOPY --from=composer:2.8.1 \/usr\/bin\/composer \/usr\/bin\/composer\n\n# \u30b5\u30fc\u30d0\u30fc\u5074\nRUN apt-get update \\\n&amp;&amp; apt-get install -y \\\nzip \\\nunzip \\\nvim \\\nlibzip-dev\n# xdebug\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\nRUN pecl install xdebug\nRUN docker-php-ext-enable xdebug\n# PHP\nRUN docker-php-ext-install zip pdo_mysql mysqli\n#mod_rewrite\u6709\u52b9\u5316\nRUN&nbsp; a2enmod rewrite<\/code><\/pre>\n\n\n\n<p><strong>2.\u30c6\u30b9\u30c8\u9805\u76ee\u3092\u66f8\u304d\u51fa\u3059<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ --------------------------------------------------\n\/\/ FizzBuzz\u30c6\u30b9\u30c8\u9805\u76ee\n\/\/ --------------------------------------------------\n\/\/ 3\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fFizz\u3092\u8fd4\u3059\n\/\/ 5\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fBuzz\u3092\u8fd4\u3059\n\/\/ 3\u3067\u30825\u3067\u3082\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fFizzBuzz\u3092\u8fd4\u3059\n\/\/ 3\u3067\u30825\u3067\u3082\u5272\u308a\u5207\u308c\u306a\u3044\u3068\u304d\u306f\u6e21\u3057\u305f\u5024\u3092\u8fd4\u3059<\/code><\/pre>\n\n\n\n<p><strong>3.1\u3064\u76ee\u306e\u30c6\u30b9\u30c8\u300c3\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fFizz\u3092\u8fd4\u3059\u300d\u306e\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace Tests\\Feature;\n\nuse Tests\\TestCase;\n\nclass FizzBuzzTest extends TestCase\n{\n&nbsp; &nbsp; \/**\n&nbsp; &nbsp; * convert\u30e1\u30bd\u30c3\u30c9\u306e\u78ba\u8a8d\n&nbsp; &nbsp; *\/\n&nbsp; &nbsp; public function test_3\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fFizz\u3092\u8fd4\u3059(): void\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; \/\/ FizzBuzz\u30af\u30e9\u30b9\u3092\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5316\n&nbsp; &nbsp; &nbsp; &nbsp; $fizz_buzz_class = new FizzBuzz();\n&nbsp; &nbsp; &nbsp; &nbsp; \/\/ FizzBuzz\u30af\u30e9\u30b9\u306econvert\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u3066\u5f15\u65709\u3092\u6e21\u3057\u305f\u623b\u308a\u5024\u304cFizz\u3068\u7b49\u3057\u3044\u5834\u5408\u306f\u30c6\u30b9\u30c8\u304c\u6b63\u5e38\u7d42\u4e86\u3059\u308b\u3002\n&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;assertEquals('Fizz', $fizz_buzz_class-&gt;convert(9));\n&nbsp; &nbsp; }\n\n}<\/code><\/pre>\n\n\n\n<p>\u30e1\u30bd\u30c3\u30c9\u540d\u306ftest_\u304b\u3089\u59cb\u3081\u308b\u3053\u3068\u3067\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3067\u3042\u308b\u3068\u8a8d\u8b58\u3055\u308c\u308b\u3002<br>\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u305f\u6642\u70b9\u3067\u306f\u3001\u307e\u3060FizzBuzz\u30af\u30e9\u30b9\u306f\u5b58\u5728\u3057\u3066\u3044\u306a\u3044\u72b6\u614b\u304c\u6b63\u3057\u3044\u3002<\/p>\n\n\n\n<p><strong>4.\u30c6\u30b9\u30c8\u5b9f\u884c<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php vendor\/bin\/phpunit<\/code><\/pre>\n\n\n\n<p>\u307e\u3060\u5b9f\u88c5\u30b3\u30fc\u30c9\u304c\u306a\u3044\u305f\u3081\u3001\u30a8\u30e9\u30fc\u304c\u51fa\u308b\u3053\u3068\u3092\u60f3\u5b9a<\/p>\n\n\n\n<p><strong>5.\u30c6\u30b9\u30c8\u7d50\u679c<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeTfJIeunwhXfEg0QkZ-oNZAy-ljsoVF85eWiNcve0vKxLTE0VUp2l7LOApYOWVZWalIVHMoBjhEQVI1vCUaDVww5peH2AT_85EMMzSsC9d-YQTvbhB0hN3ITiE3feSfwWdDwDApA?key=VL215w2CC1vcOjHt50LOfZEy\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u60f3\u5b9a\u901a\u308a\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXe_Os0ZukFwOdJls4bCaAkWCbtQ9VWTlkH0N7ehMK72EG1DCSA5QTBXxVt_WIdfegbdgfFjA_Ln4MXOIOFjfHBPKOiADtp8ReFbHM5HXpc4zRGcrJrMKurcdZvJJGzesRA6oUatQQ?key=VL215w2CC1vcOjHt50LOfZEy\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>6. \u30a8\u30e9\u30fc\u306b\u306a\u3063\u305f\u30c6\u30b9\u30c8\u304c\u6210\u529f\u3059\u308b\u3088\u3046\u306a\u5b9f\u88c5\u30b3\u30fc\u30c9\u3092\u66f8<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&nbsp; public function FizzBuzz(int $number): string\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; if($number % 3 == 0){\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 'Fizz';&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}\n&nbsp; &nbsp; }<\/code><\/pre>\n\n\n\n<p><strong>7.\u30c6\u30b9\u30c8\u3092\u518d\u5ea6\u5b9f\u884c\u3057\u305f\u7d50\u679c<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXc_8T_BRqj9Gv6QEG4QTvhCIB5PKveEcCg5U3BVkNTm9Cz5_U5ETBWYzF9Wi_M8YOy67ErbbyV50jv0W9tzTSwlRK7NyO7-aSqJf2Cq_pJo-8HUaVM7SCXZUv7aIhphbeeZCv3d?key=VL215w2CC1vcOjHt50LOfZEy\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>8.\u30c6\u30b9\u30c8\u304c\u6210\u529f\u3057\u305f\u305f\u3081\u30ea\u30d5\u30a1\u30af\u30bf\u30ea\u30f3\u30b0\u3092\u884c\u3046\u3002<\/strong><\/p>\n\n\n\n<p><strong>9.\u3053\u308c\u3092\u30c6\u30b9\u30c8\u9805\u76ee\u5206\u7e70\u308a\u8fd4\u3059\u3002<\/strong><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5b8c\u6210\u30b3\u30fc\u30c9<\/h1>\n\n\n\n<p>tests\/Feature\/FizzBuzzTest.php<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace Tests\\Feature;\n\nuse Tests\\TestCase;\nuse App\\FizzBuzz;\n\nclass FizzBuzzTest extends TestCase\n{\n&nbsp; &nbsp; \/**\n&nbsp; &nbsp; * convert\u30e1\u30bd\u30c3\u30c9\u306e\u78ba\u8a8d\n&nbsp; &nbsp; *\/\n&nbsp; &nbsp; public function test_3\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fFizz\u3092\u8fd4\u3059(): void\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; $fizz_buzz_class = new FizzBuzz();\n&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;assertEquals('Fizz', $fizz_buzz_class-&gt;convert(9));\n&nbsp; &nbsp; }\n&nbsp; &nbsp;\n&nbsp; &nbsp; public function test_5\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fBuzz\u3092\u8fd4\u3059(): void\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; $fizz_buzz_class = new FizzBuzz();\n&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;assertEquals('Buzz', $fizz_buzz_class-&gt;convert(10));\n&nbsp; &nbsp; }\n\n&nbsp; &nbsp; public function test_3\u30685\u306e\u4e21\u65b9\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306fFizzBuzz\u3092\u8fd4\u3059(): void\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; $fizzBuzz = new FizzBuzz();\n&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;assertEquals('FizzBuzz', $fizzBuzz-&gt;convert(15));\n&nbsp; &nbsp; }\n\n&nbsp; &nbsp; public function test_3\u3067\u30825\u3067\u3082\u5272\u308a\u5207\u308c\u306a\u3044\u5834\u5408\u306f\u6570\u5b57\u3092\u8fd4\u3059(): void\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; $fizzBuzz = new FizzBuzz();\n&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;assertEquals('7', $fizzBuzz-&gt;convert(7));\n&nbsp; &nbsp; }\n\n&nbsp; &nbsp; \/**\n&nbsp; &nbsp; * FizzBuzz\u95a2\u6570\u30c6\u30b9\u30c8\n&nbsp; &nbsp; *\/\n&nbsp; &nbsp; public function test_1\u304b\u308915\u307e\u3067\u306e\u6570\u5b57\u3067FizzBuzz\u306e\u691c\u8a3c\u3059\u308b(): void\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; $fizzBuzz = new FizzBuzz();\n&nbsp; &nbsp; &nbsp; &nbsp; $this-&gt;assertEquals('12Fizz4BuzzFizz78FizzBuzz11Fizz1314FizzBuzz', $fizzBuzz-&gt;fizzBuzz(15));\n&nbsp; &nbsp; }\n}<\/code><\/pre>\n\n\n\n<p>app\/FizzBuzz.php<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace App;\n\nclass FizzBuzz\n{\n&nbsp; &nbsp; \/**\n&nbsp; &nbsp; * - 3\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306f\u300cFizz\u300d\u3092\u8fd4\u3059\n&nbsp; &nbsp; * - 5\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306f\u300cBuzz\u300d\u3092\u8fd4\u3059\n&nbsp; &nbsp; * - \u4e21\u65b9\u3067\u5272\u308a\u5207\u308c\u308b\u3068\u304d\u306f\u300cFizzBuzz\u300d\u3092\u8fd4\u3059\n&nbsp; &nbsp; * - \u4e0a\u8a18\u4ee5\u5916\u306e\u5834\u5408\u3001\u6570\u5b57\u3092\u8fd4\u3059\n&nbsp; &nbsp; *\n&nbsp; &nbsp; * @param int $number\n&nbsp; &nbsp; * @return int|string\n&nbsp; &nbsp; *\/\n&nbsp; &nbsp; public function convert(int $number): int|string\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; if ($number % 3 === 0 &amp;&amp; $number % 5 === 0) {\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 'FizzBuzz';\n&nbsp; &nbsp; &nbsp; &nbsp; } elseif ($number % 5 === 0) {\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 'Buzz';\n&nbsp; &nbsp; &nbsp; &nbsp; } elseif ($number % 3 === 0) {\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return 'Fizz';\n&nbsp; &nbsp; &nbsp; &nbsp; }\n&nbsp; &nbsp; &nbsp; &nbsp; return $number;\n&nbsp; &nbsp; }\n\n&nbsp; &nbsp; \/**\n&nbsp; &nbsp; * \u6e21\u3055\u308c\u305f\u6570\u5024\u307e\u3067\u306e\u6570\u5b57\u3092\u5909\u63db\u3057\u305f\u7d50\u679c\u3092\u8fd4\u3059\n&nbsp; &nbsp; *\n&nbsp; &nbsp; * @param int $count\n&nbsp; &nbsp; * @return string\n&nbsp; &nbsp; *\/\n&nbsp; &nbsp; public function fizzBuzz(int $count): string\n&nbsp; &nbsp; {\n&nbsp; &nbsp; &nbsp; &nbsp; $result = '';\n&nbsp; &nbsp; &nbsp; &nbsp; for ($i = 0; $i &lt; $count; $i++) {\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $result .= $this-&gt;convert($i + 1);\n&nbsp; &nbsp; &nbsp; &nbsp; }\n&nbsp; &nbsp; &nbsp; &nbsp; return $result;\n&nbsp; &nbsp; }\n}<\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u72b6\u614b\u3067\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdxbUUPdC9Trq42Qfcl3uTN1wyFNmQJ67kzosq6VxgoQRJadp9JxwcrMI7qF8q1R-nt1l4Zzq2asonzZ-eAVCNS5EePNVYD1OgywzM2yRLWvMP_3hhdMwmFmj7Uc5glPePgnFko?key=VL215w2CC1vcOjHt50LOfZEy\" alt=\"\"\/><\/figure>\n\n\n\n<p>\u5b8c\u6210\u3057\u307e\u3057\u305f\uff01<\/p>\n\n\n\n<p>\u30c6\u30b9\u30c8\u304c\u5168\u3066\u901a\u308b\u3068\u6c17\u6301\u3061\u304c\u826f\u3044\u3067\u3059\u306d\uff5e\uff01<br>\u7d9a\u3044\u3066\u3001\u79c1\u304c\u5b9f\u969b\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u969b\u306b\u8e93\u3044\u305f\u70b9\u3092\u5171\u6709\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u8e93\u3044\u305f\u70b9<\/h1>\n\n\n\n<p><strong>\u30fb\u30c6\u30b9\u30c8\u306e\u7c92\u5ea6<\/strong><br>TDD\u306e\u30b5\u30a4\u30af\u30eb\u3092\u3069\u308c\u304f\u3089\u3044\u7d30\u304b\u304f\u884c\u3046\u3079\u304d\u304b\u304c\u6c7a\u307e\u3089\u306a\u3044\u307e\u307e\u958b\u767a\u3092\u884c\u3063\u3066\u3057\u307e\u3044\u3001\u9014\u4e2d\u3067\u7c92\u5ea6\u3092\u5909\u3048\u308b\u3053\u3068\u3067\u60f3\u5b9a\u5de5\u6570\u3088\u308a\u3082\u30aa\u30fc\u30d0\u30fc\u3057\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3057\u305f\u3002<br>\u6c7a\u3081\u306e\u554f\u984c\u3067\u3059\u304c\u3001\u81ea\u5206\u304c\u7d0d\u5f97\u306e\u884c\u304f\u7c92\u5ea6\u3067TDD\u3092\u884c\u3044\u307e\u3057\u3087\u3046\uff01<\/p>\n\n\n\n<p><strong>\u30fb\u6d41\u308c<\/strong><br>\u300c\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u2192\u5b9f\u88c5\u30b3\u30fc\u30c9\u300d\u3068\u3044\u3046\u6d41\u308c\u3067\u66f8\u304b\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u6700\u521d\u306e\u3046\u3061\u306f\u3069\u3046\u3057\u3066\u3082\u5b9f\u88c5\u30b3\u30fc\u30c9\u3092\u5148\u306b\u66f8\u3044\u3066\u3057\u307e\u3046\u3053\u3068\u304c\u3042\u308a\u307e\u3057\u305f\u3002<br>\u6163\u308c\u306a\u3044\u3046\u3061\u306f\u5927\u5909\u3067\u3059\u304c\u3001\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u304b\u3089\u5148\u306b\u304b\u304f\u3053\u3068\u3067\u3001\u5b9f\u88c5\u3059\u308b\u6a5f\u80fd\u306e\u8981\u4ef6\u3092\u660e\u78ba\u306b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ed5\u69d8\u3092\u78ba\u8a8d\u3057\u306a\u304c\u3089\u5b9f\u88c5\u3092\u9032\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u305f\u3081\u3001\u5fc5\u305a\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u304b\u3089\u66f8\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n\n\n\n<p><strong>\u30fb\u5de5\u6570<\/strong><br>\u5b9f\u88c5\u30b3\u30fc\u30c9\u3060\u3051\u3092\u66f8\u304f\u3088\u308a\u3082\u3001\u660e\u3089\u304b\u306b\u5de5\u6570\u304c\u304b\u304b\u308a\u307e\u3059\u3002<br>\u5b9f\u969b\u306b\u79c1\u306f\u3001\u3088\u304f\u3042\u308b\u30ed\u30b0\u30a4\u30f3\u753b\u9762\u306e\u958b\u767a\u3092TDD\u3067\u884c\u3063\u305f\u969b\u3001\u5b9f\u88c5\u30b3\u30fc\u30c9\u306e\u307f\u306e\u958b\u767a\u306b\u6bd4\u3079\u3066\u7d043\u500d\u306e\u5de5\u6570\u304c\u304b\u304b\u3063\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u6700\u521d\u306f\u5b9f\u969b\u306b\u639b\u304b\u3063\u305f\u5de5\u6570\u3092\u898b\u3066\u843d\u3061\u8fbc\u307f\u307e\u3057\u305f\u304c\u3001\u30d0\u30b0\u304c\u5c11\u306a\u304f\u3001\u30e1\u30f3\u30c6\u30ca\u30f3\u30b9\u6027\u306e\u9ad8\u3044\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u305f\u3081\u306b\u306f\u5fc5\u8981\u306a\u306e\u3067\u3001\u521d\u671f\u6295\u8cc7\u3060\u3068\u8003\u3048\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\uff01<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u304a\u308f\u308a\u306b<\/h1>\n\n\n\n<p>\u6700\u5f8c\u307e\u3067\u8aad\u3093\u3067\u304f\u3060\u3055\u3063\u3066\u3042\u308a\u304c\u3068\u3046\u3054\u3056\u3044\u307e\u3057\u305f\uff01<br>\u307e\u3060\u30c6\u30b9\u30c8\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u305f\u3053\u3068\u304c\u306a\u3044\u65b0\u4eba\u30a8\u30f3\u30b8\u30cb\u30a2\u3067\u3082\u3001TDD\u958b\u767a\u624b\u6cd5\u306b\u6311\u6226\u3057\u3084\u3059\u3044\u8a18\u4e8b\u306b\u306a\u3063\u3066\u3044\u308c\u3070\u5e78\u3044\u3067\u3059\uff01<br>\u3053\u308c\u304b\u3089\u3082RSS\u306e\u30e1\u30f3\u30d0\u30fc\u304c\u30d6\u30ed\u30b0\u3092\u6295\u7a3f\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<a href=\"https:\/\/race-ss.co.jp\/\" class=\"corp-link-btn\" target=\"_blank\" rel=\"noopener\">\n  <div class=\"corp-link-img\">\n    <img decoding=\"async\" src=\"https:\/\/race-ss.co.jp\/blog\/wp-content\/uploads\/2025\/11\/\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u753b\u50cf-2.jpg\">\n  <\/div>\n  <div class=\"corp-link-text\">\n    <div class=\"corp-link-title\">\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u4e2d\uff01<\/div>\n    <div class=\"corp-link-desc\">\n      \u30ec\u30a4\u30b9\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\uff08\u30b3\u30fc\u30dd\u30ec\u30fc\u30c8\u30b5\u30a4\u30c8\uff09\n    <\/div>\n  <\/div>\n<\/a>\n\n<div class=\"contact-section-compact\">\n  <p class=\"contact-compact-text\">\n    \u30ec\u30a4\u30b9\u30b7\u30b9\u30c6\u30e0\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u30ba\u682a\u5f0f\u4f1a\u793e\u306e\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u958b\u767a\u3084\u3001<br>\n    \u63a1\u7528\u306b\u95a2\u3059\u308b\u304a\u554f\u3044\u5408\u308f\u305b\u306b\u3064\u3044\u3066\u306f\u3001\u4e0b\u8a18\u306e\u30ea\u30f3\u30af\u306b\u3066\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002\n  <\/p>\n  \n  <a href=\"https:\/\/docs.google.com\/forms\/d\/e\/1FAIpQLSdZuEol6gkLjICDDsr9JsYTjmJMOllj7ew4aQZOilqQinCuzw\/viewform\" class=\"contact-compact-btn\" target=\"_blank\" rel=\"noopener\">\n    <svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"currentColor\" style=\"margin-right:8px; vertical-align:middle;\">\n      <path d=\"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z\"\/>\n    <\/svg>\n    \u304a\u554f\u3044\u5408\u308f\u305b\n  <\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f\uff01RSS\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306eK.A.\u3067\u3059\u3002 \u4eca\u56de\u306f\u3001\u30c6\u30b9\u30c8\u521d\u5fc3\u8005\u5411\u3051\u306e\u30c6\u30fc\u30de\u3068\u3057\u3066\u3001\u300cPHPUnit\u3092\u4f7f\u3063\u305fFizzBuzz\u554f\u984c\u5b9f\u88c5\u300d\u306b\u3064\u3044\u3066\u304a\u8a71\u3057\u3057\u307e\u3059\uff01\u3053\u306e\u30c6\u30fc\u30de\u306e\u8a18\u4e8b\u3092\u66f8\u3053\u3046\u3068\u601d\u3063\u305f\u80cc\u666f\u3068\u3057\u3066\u306f\u3001\u521d\u3081\u3066\u30c6\u30b9\u30c8\u99c6 [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":1130,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"footnotes":""},"categories":[168,35],"tags":[181,184,182,183,153],"class_list":["post-1126","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ci-cddevops","category-35","tag-php","tag-phpunit","tag-tdd","tag-183","tag-153"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1126"}],"version-history":[{"count":11,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1126\/revisions"}],"predecessor-version":[{"id":1508,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1126\/revisions\/1508"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=\/wp\/v2\/media\/1130"}],"wp:attachment":[{"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/race-ss.co.jp\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}