Back Button Testing

Code Katas with PHPUnit

If martial artists use kata as a method for exercise and practice, what might be the equivalent for coders like us? Coding katas are short, repeatable programming challenges which are meant to exercise everything from your focus, to your workflow.

In this series, one kata per episode, we'll work through a wide variety of challenges to build up your TDD process.

6 episodes
1:58:06 hrs
Start Series
  • Latest Episode: Tennis Match Kata

  • Like this series? Share the love!

    1. Kata is a martial arts term from Japan that refers to a choreographed sequence of movements. The goal is to perfect and internalize these movements through repetition and memorization. Once mastered, these sequences serve as a reference guide that you can instantly reach for and adapt without thought.

      Outside of martial arts, this word, kata, is used more generally to refer to any set of steps or patterns that is repeated until mastery. Think of it as a way to harness your form and routine.

    2. Run Time 51 Free

      Before we attempt our first coding kata, let's first take a moment to setup a base directory for our exercises. We'll use Composer to pull in PHPUnit and then register PSR-4 autoloading for the project.

    3. Run Time 14:55 Free

      First up is the prime factors Kata. A prime number is a number that is only divisible by itself and one (2, 3, 5, 7, 11...). Further, for any given number, we can generate its prime factors by reducing it down to exclusively prime numbers that, when multiplied, equal the number in question. In this lesson, we'll use TDD to create a class that can generate all prime factors for a number.

      View the source code for this episode on GitHub.

    4. Run Time 16:47

      Next up is the popular Roman numerals challenge. Our job is to create a class using TDD that can generate the corresponding Roman numeral for a provided number. To provide a few examples, 1 should return "I", 6 should return "VI", and 10 should return "X".

      View the source code for this episode on GitHub.

    5. Run Time 23:40

      I bet you didn't expect to learn the rules of Bowling on Laracasts, but here we are. In this lesson, we'll use TDD to record and score a completed bowling game.

      View the source code for this episode on GitHub.

    6. Next up is the string calculator kata. Our job is to create a class with a single public method that accepts a string of numbers to add. However, as part of the kata, a number of requirements must first be met, such as disallowing negative numbers and ignoring numbers greater than 1,000. Let's get started.

      View the source code for this episode on GitHub.

    7. Run Time 36:50 New

      Now that you've learned how to score a bowling game, let's move on to a Tennis match. This one is a bit more complicated, but well worth the effort.

      Once you've completed the video, take a look at the source code to see how I solved the small homework challenge at the end of the video on GitHub.

Series still in development robot

*Series still in development. Check back often for updates.