Skip to content

Commit

Permalink
Fixes #1023
Browse files Browse the repository at this point in the history
[BC BREAK]

The numeric comparator is no longer invoked when provided with two strings.
  • Loading branch information
whatthejeff committed Oct 12, 2013
1 parent 1c26eb5 commit f5df97c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion PHPUnit/Framework/Comparator/Numeric.php
Expand Up @@ -67,7 +67,10 @@ class PHPUnit_Framework_Comparator_Numeric extends PHPUnit_Framework_Comparator_
public function accepts($expected, $actual)
{
// all numerical values, but not if one of them is a double
return is_numeric($expected) && is_numeric($actual) && !(is_double($expected) || is_double($actual));
// or both of them are strings
return is_numeric($expected) && is_numeric($actual) &&
!(is_double($expected) || is_double($actual)) &&
!(is_string($expected) && is_string($actual));
}

/**
Expand Down
2 changes: 2 additions & 0 deletions Tests/Framework/AssertTest.php
Expand Up @@ -651,6 +651,8 @@ protected function notEqualValues()
// strings
array('a', 'b'),
array('a', 'A'),
// https://github.com/sebastianbergmann/phpunit/issues/1023
array('9E6666666','9E7777777'),
// integers
array(1, 2),
array(2, 1),
Expand Down
2 changes: 1 addition & 1 deletion Tests/Framework/ComparatorTest.php
Expand Up @@ -73,7 +73,7 @@ public function instanceProvider()
array(TRUE, FALSE, 'PHPUnit_Framework_Comparator_Scalar'),
array(FALSE, TRUE, 'PHPUnit_Framework_Comparator_Scalar'),
array('', '', 'PHPUnit_Framework_Comparator_Scalar'),
array('0', '0', 'PHPUnit_Framework_Comparator_Numeric'),
array('0', '0', 'PHPUnit_Framework_Comparator_Scalar'),
array('0', 0, 'PHPUnit_Framework_Comparator_Numeric'),
array(0, '0', 'PHPUnit_Framework_Comparator_Numeric'),
array(0, 0, 'PHPUnit_Framework_Comparator_Numeric'),
Expand Down

0 comments on commit f5df97c

Please sign in to comment.