VoiceGem

How to dictate a PHPUnit test method

PHPUnit test methods dictate with no cleanup at all. “public function camel case test get user open paren close paren colon void open brace” returns public function testGetUser(): void { exactly, because every character involved binds the way PHP formats it.

A thirteen-word PHPUnit declaration is about 15 seconds of typing against about 4.8 seconds of speech. (sources: Dhakal, Feit, Kristensson & Oulasvirta, “Observations on Typing from 136 Million Keystrokes”, CHI 2018, 168,000 participants, 136 million keystrokes; Yuan, Liberman & Cieri, “Towards an Integrated Understanding of Speaking Rate in Conversation”, Interspeech 2006, 2,438 American English telephone conversations (Switchboard corpus). The speech figure is conversational rate, not a measured dictation rate — no such measurement exists.)

What lands in your editor
public function testGetUserReturnsCachedRecord(): void {

This tool runs entirely in your browser. Nothing you type is sent anywhere, stored, or logged.

Step by step

  1. 1

    Say the modifiers plainly

    Speak “public function”. Neither word is in VoiceGem's lookup table, so both pass through untouched.

  2. 2

    Name the method with a casing command

    Say “camel case test get user returns cached record”. PHPUnit discovers methods prefixed with test, and the run builds the whole name in one go.

  3. 3

    Add the return type

    Say “close paren colon void”. The colon attaches left, which is exactly how PHP writes a return type declaration.

  4. 4

    Expect the arrow to be spaced

    Close the gap around thin arrows in the body. Assertions on $this arrive as $this -> assertSame, because the thin arrow attaches on neither side.

PHPUnit declarations dictate cleanly and PHPUnit assertions do not

The split runs along one character. Everything in the method declaration — modifiers, the camelCase name, the bracket pair, the return-type colon and the brace — binds correctly, so the header arrives ready to run.

Assertions go through $this and a thin arrow, and the thin arrow attaches on neither side in VoiceGem's table. Every assertion line therefore needs one space removed, which a PHP formatter handles on save but which is worth expecting rather than discovering.

Where the manual path breaks

PhpStorm generates PHPUnit methods and completes assertion names, which is faster than dictating either. Tooling wins on the structure.

Long test method names are the remaining case. PHPUnit's convention produces camelCase names of five or six words describing the behaviour under test, and every word boundary is a shift press. Dictating the name in VoiceGem is one casing command and the sentence you were already thinking.

Doing this somewhere else? speech-to-code converter, in one place, how dictating PHP functions works, dictating PHP regular expressions, step by step, or how dictating Go tests works.

Common questions

No. Every character in the header binds the way PHP formats it, so VoiceGem returns a method signature that is ready to run.

The thin arrow attaches on neither side, so $this -> assertSame arrives with a space. Your formatter closes it on save.

Say “at sign pascal case data provider new line”. The line break ends the casing run before the next keyword is absorbed.

Dictate a test method and an assertion and compare the two.

Open the tool