Posts

Showing posts from May, 2021

Preserving test cases when removing the tested classes

In my - most likely - final days of PHP development, I thought about writing something related to PHP. I had this topic on my todo list for some time. It is about testing. It is a strategy, actually 2 of them, that I often used to cover my arse when refactoring code. I have talked about it verbally but, in my opinion, writing information down is always a good thing. The whole idea is described in  https://github.com/varfrog/testing-topic . The content below is a copy-paste of the README from Github. Scenario There is a class  \App\Example1\Formatter  with a single public method  format(string) . This method receives a string, reverses the sequence if its words, and in the resulting set of words appends an increasing natural number to each word. For example: Input Output a b c c1 b2 a3 foo bar baz baz1 bar2 foo3 This method is unit-tested, see  \App\Example1\Tests\Unit\FormatterTest . It tests that the method correctly transforms the text as in the table above: # FormatterTestCase self