Skip to content

Commit

Permalink
Added some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tersmitten committed Jun 10, 2015
1 parent 49952d8 commit 5a7333f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/DamerauLevenshtein.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ protected function compare($firstCharacter, $secondCharacter)
*/
public function displayMatrix()
{
$this->setupMatrix();

$oneSize = mb_strlen($this->compOne, 'UTF-8');
$twoSize = mb_strlen($this->compTwo, 'UTF-8');

Expand Down
53 changes: 47 additions & 6 deletions tests/DamerauLevenshteinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DamerauLevenshteinTest extends \PHPUnit_Framework_TestCase
{

/**
* Test for `getSimilarity`.
* Tests `getSimilarity`.
*
* @return void
*/
Expand Down Expand Up @@ -62,7 +62,7 @@ public function testGetSimilarity()
}

/**
* Test for `getInsCost`.
* Tests `getInsCost`.
*
* @return void
*/
Expand Down Expand Up @@ -98,7 +98,7 @@ public function testGetInsCost()
}

/**
* Test for `getDelCost`.
* Tests `getDelCost`.
*
* @return void
*/
Expand Down Expand Up @@ -134,7 +134,7 @@ public function testGetDelCost()
}

/**
* Test for `getSubCost`.
* Tests `getSubCost`.
*
* @return void
*/
Expand Down Expand Up @@ -170,7 +170,7 @@ public function testGetSubCost()
}

/**
* Test for `getTransCost`.
* Tests `getTransCost`.
*
* @return void
*/
Expand Down Expand Up @@ -206,7 +206,7 @@ public function testGetTransCost()
}

/**
* Test for `getRelativeDistance`.
* Tests `getRelativeDistance`.
*
* @return void
*/
Expand Down Expand Up @@ -255,6 +255,47 @@ public function testGetRelativeDistance()
$this->assertEquals($expected, $result, '', $delta);
}

/**
* Tests `getMatrix`.
*
* @return void
*/
public function testGetMatrix()
{
list($firstString, $secondString) = $this->getDefaultStrings();

$DamerauLevenshtein = new DamerauLevenshtein($firstString, $secondString);
$actual = $DamerauLevenshtein->getMatrix();
$expected = array(
array(0, 1, 2, 3),
array(1, 1, 2, 3),
array(2, 2, 2, 3),
array(3, 3, 3, 3)
);
$this->assertSame($expected, $actual);
}

/**
* Tests `displayMatrix`.
*
* @return void
*/
public function testDisplayMatrix()
{
list($firstString, $secondString) = $this->getDefaultStrings();

$DamerauLevenshtein = new DamerauLevenshtein($firstString, $secondString);
$actual = $DamerauLevenshtein->displayMatrix();
$expected = implode('', array(
" foo\n",
" 0123\n",
"b1123\n",
"a2223\n",
"r3333\n",
));
$this->assertSame($expected, $actual);
}

/**
* Returns the default costs.
*
Expand Down

0 comments on commit 5a7333f

Please sign in to comment.