usePHPUnit\Framework\TestCase;classGetEvolutionRateMessageTestextendsTestCase{publicfunctiontestShouldReturnPositiveRateMessage(){$this->assertEquals(getEvolutionRateMessage(11.29,45.79),"A positive evolution of 306%");}publicfunctiontestShouldReturnOtherPositiveRateMessage(){$this->assertEquals(getEvolutionRateMessage(0,27.35),"A positive evolution of 2735%");}publicfunctiontestShouldReturnNegativeRateMessage(){$this->assertEquals(getEvolutionRateMessage(95.12,66.84),"A negative evolution of 30%");}publicfunctiontestShouldReturnOtherNegativeRateMessage(){$this->assertEquals(getEvolutionRateMessage(41.26,0),"A negative evolution of 4126%");}publicfunctiontestShouldReturnZeroEvolutionMessage(){$this->assertEquals(getEvolutionRateMessage(1.26,1.26),"No evolution");}}
Since no one proposed a PHP solution, here I am!
getEvolutionRate()
unit tests:getEvolutionRateMessage()
unit tests:I love those guards you are puting in your code. Really makes me want to go back and do PHP with you like the good ol'times!
Let's do a side project together