Permalink
Browse files

Fix #132.

  • Loading branch information...
1 parent 13ca494 commit 36625b66753b681749f42f457e0c1072cc57ce55 @sebastianbergmann committed May 26, 2007
Showing with 68 additions and 0 deletions.
  1. +68 −0 PHPUnit/Assert.php
View
@@ -178,6 +178,74 @@ function assertEquals($expected, $actual, $message = '', $delta = 0) {
}
/**
+ * Asserts that two variables are not equal.
+ *
+ * @param mixed
+ * @param mixed
+ * @param string
+ * @param mixed
+ * @access public
+ */
+ function assertNotEquals($expected, $actual, $message = '', $delta = 0) {
+ if ((is_array($actual) && is_array($expected)) ||
+ (is_object($actual) && is_object($expected))) {
+ if (is_array($actual) && is_array($expected)) {
+ ksort($actual);
+ ksort($expected);
+ }
+
+ if ($this->_looselyTyped) {
+ $actual = $this->_convertToString($actual);
+ $expected = $this->_convertToString($expected);
+ }
+
+ $actual = serialize($actual);
+ $expected = serialize($expected);
+
+ $message = sprintf(
+ '%sexpected %s, actual %s',
+
+ !empty($message) ? $message . ' ' : '',
+ $expected,
+ $actual
+ );
+
+ if ($actual == $expected) {
+ return $this->fail($message);
+ }
+ }
+
+ elseif (is_numeric($actual) && is_numeric($expected)) {
+ $message = sprintf(
+ '%sexpected %s%s, actual %s',
+
+ !empty($message) ? $message . ' ' : '',
+ $expected,
+ ($delta != 0) ? ('+/- ' . $delta) : '',
+ $actual
+ );
+
+ if (($actual >= ($expected - $delta) && $actual <= ($expected + $delta))) {
+ return $this->fail($message);
+ }
+ }
+
+ else {
+ $message = sprintf(
+ '%sexpected %s, actual %s',
+
+ !empty($message) ? $message . ' ' : '',
+ $expected,
+ $actual
+ );
+
+ if ($actual == $expected) {
+ return $this->fail($message);
+ }
+ }
+ }
+
+ /**
* Asserts that two variables reference the same object.
* This requires the Zend Engine 2 to work.
*

0 comments on commit 36625b6

Please sign in to comment.