1--TEST-- 2levenshtein() function test 3--FILE-- 4<?php 5 6echo '--- Equal ---' . \PHP_EOL; 7var_dump(levenshtein('12345', '12345')); 8 9echo '--- First string empty ---' . \PHP_EOL; 10var_dump(levenshtein('', 'xyz')); 11echo '--- Second string empty ---' . \PHP_EOL; 12var_dump(levenshtein('xyz', '')); 13echo '--- Both empty ---' . \PHP_EOL; 14var_dump(levenshtein('', '')); 15var_dump(levenshtein('', '', 10, 10, 10)); 16 17echo '--- 1 character ---' . \PHP_EOL; 18var_dump(levenshtein('1', '2')); 19echo '--- 2 character swapped ---' . \PHP_EOL; 20var_dump(levenshtein('12', '21')); 21 22echo '--- Inexpensive deletion ---' . \PHP_EOL; 23var_dump(levenshtein('2121', '11', 2)); 24echo '--- Expensive deletion ---' . \PHP_EOL; 25var_dump(levenshtein('2121', '11', 2, 1, 5)); 26 27echo '--- Inexpensive insertion ---' . \PHP_EOL; 28var_dump(levenshtein('11', '2121')); 29echo '--- Expensive insertion ---' . \PHP_EOL; 30var_dump(levenshtein('11', '2121', 5)); 31 32echo '--- Expensive replacement ---' . \PHP_EOL; 33var_dump(levenshtein('111', '121', 2, 3, 2)); 34echo '--- Very expensive replacement ---' . \PHP_EOL; 35var_dump(levenshtein('111', '121', 2, 9, 2)); 36 37?> 38--EXPECT-- 39--- Equal --- 40int(0) 41--- First string empty --- 42int(3) 43--- Second string empty --- 44int(3) 45--- Both empty --- 46int(0) 47int(0) 48--- 1 character --- 49int(1) 50--- 2 character swapped --- 51int(2) 52--- Inexpensive deletion --- 53int(2) 54--- Expensive deletion --- 55int(10) 56--- Inexpensive insertion --- 57int(2) 58--- Expensive insertion --- 59int(10) 60--- Expensive replacement --- 61int(3) 62--- Very expensive replacement --- 63int(4) 64