Skip to content

Instantly share code, notes, and snippets.

@mathiasverraes
Created November 25, 2011 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathiasverraes/1393879 to your computer and use it in GitHub Desktop.
Save mathiasverraes/1393879 to your computer and use it in GitHub Desktop.
Assert that two strings are close to each other. #phpunit
<?php
protected function assertStringDistanceInPercent($minimumPercentage, $expected, $actual)
{
$percentage = 0;
similar_text($expected, $actual, $percentage);
$this->assertGreaterThanOrEqual(
$minimumPercentage,
$percentage,
"The distance between the strings should be greater than or equal to $minimumPercentage%, got $percentage%");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment