You are here

public function Framework_ConstraintTest::isEqualProvider in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php \Framework_ConstraintTest::isEqualProvider()

File

vendor/phpunit/phpunit/tests/Framework/ConstraintTest.php, line 617

Class

Framework_ConstraintTest
@since Class available since Release 3.0.0

Code

public function isEqualProvider() {
  $a = new stdClass();
  $a->foo = 'bar';
  $b = new stdClass();
  $ahash = spl_object_hash($a);
  $bhash = spl_object_hash($b);
  $c = new stdClass();
  $c->foo = 'bar';
  $c->int = 1;
  $c->array = array(
    0,
    array(
      1,
    ),
    array(
      2,
    ),
    3,
  );
  $c->related = new stdClass();
  $c->related->foo = "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk";
  $c->self = $c;
  $c->c = $c;
  $d = new stdClass();
  $d->foo = 'bar';
  $d->int = 2;
  $d->array = array(
    0,
    array(
      4,
    ),
    array(
      2,
    ),
    3,
  );
  $d->related = new stdClass();
  $d->related->foo = "a\np\nc\nd\ne\nf\ng\nh\ni\nw\nk";
  $d->self = $d;
  $d->c = $c;
  $storage1 = new SplObjectStorage();
  $storage1
    ->attach($a);
  $storage1
    ->attach($b);
  $storage2 = new SplObjectStorage();
  $storage2
    ->attach($b);
  $storage1hash = spl_object_hash($storage1);
  $storage2hash = spl_object_hash($storage2);
  $dom1 = new DOMDocument();
  $dom1->preserveWhiteSpace = false;
  $dom1
    ->loadXML('<root></root>');
  $dom2 = new DOMDocument();
  $dom2->preserveWhiteSpace = false;
  $dom2
    ->loadXML('<root><foo/></root>');
  $data = array(
    array(
      1,
      0,
      <<<EOF
Failed asserting that 0 matches expected 1.

EOF
,
    ),
    array(
      1.1,
      0,
      <<<EOF
Failed asserting that 0 matches expected 1.1.

EOF
,
    ),
    array(
      'a',
      'b',
      <<<EOF
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'a'
+'b'

EOF
,
    ),
    array(
      "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk",
      "a\np\nc\nd\ne\nf\ng\nh\ni\nw\nk",
      <<<EOF
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
 'a
-b
+p

@@ @@
 i
-j
+w
 k'

EOF
,
    ),
    array(
      1,
      array(
        0,
      ),
      <<<EOF
Array (...) does not match expected type "integer".

EOF
,
    ),
    array(
      array(
        0,
      ),
      1,
      <<<EOF
1 does not match expected type "array".

EOF
,
    ),
    array(
      array(
        0,
      ),
      array(
        1,
      ),
      <<<EOF
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    0 => 0
+    0 => 1
 )

EOF
,
    ),
    array(
      array(
        true,
      ),
      array(
        'true',
      ),
      <<<EOF
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    0 => true
+    0 => 'true'
 )

EOF
,
    ),
    array(
      array(
        0,
        array(
          1,
        ),
        array(
          2,
        ),
        3,
      ),
      array(
        0,
        array(
          4,
        ),
        array(
          2,
        ),
        3,
      ),
      <<<EOF
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     0 => 0
     1 => Array (
-        0 => 1
+        0 => 4
     )
     2 => Array (...)
     3 => 3
 )

EOF
,
    ),
    array(
      $a,
      array(
        0,
      ),
      <<<EOF
Array (...) does not match expected type "object".

EOF
,
    ),
    array(
      array(
        0,
      ),
      $a,
      <<<EOF
stdClass Object (...) does not match expected type "array".

EOF
,
    ),
    array(
      $a,
      $b,
      <<<EOF
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
 stdClass Object (
-    'foo' => 'bar'
 )

EOF
,
    ),
    array(
      $c,
      $d,
      <<<EOF
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
 stdClass Object (
     'foo' => 'bar'
-    'int' => 1
+    'int' => 2
     'array' => Array (
         0 => 0
         1 => Array (
-            0 => 1
+            0 => 4

@@ @@
         'foo' => 'a
-        b
+        p

@@ @@
         i
-        j
+        w
         k'
     )
     'self' => stdClass Object (...)
     'c' => stdClass Object (...)
 )

EOF
,
    ),
    array(
      $dom1,
      $dom2,
      <<<EOF
Failed asserting that two DOM documents are equal.
--- Expected
+++ Actual
@@ @@
 <?xml version="1.0"?>
-<root/>
+<root>
+  <foo/>
+</root>

EOF
,
    ),
    array(
      new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/New_York')),
      new DateTime('2013-03-29 04:13:35', new DateTimeZone('America/Chicago')),
      <<<EOF
Failed asserting that two DateTime objects are equal.
--- Expected
+++ Actual
@@ @@
-2013-03-29T04:13:35-0400
+2013-03-29T04:13:35-0500

EOF
,
    ),
  );
  if (PHP_MAJOR_VERSION < 7) {
    $data[] = array(
      $storage1,
      $storage2,
      <<<EOF
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
-SplObjectStorage Object &{<span class="php-variable">$storage1hash</span>} (
-    '{<span class="php-variable">$ahash</span>}' => Array &0 (
-        'obj' => stdClass Object &{<span class="php-variable">$ahash</span>} (
-            'foo' => 'bar'
-        )
+SplObjectStorage Object &{<span class="php-variable">$storage2hash</span>} (
+    '{<span class="php-variable">$bhash</span>}' => Array &0 (
+        'obj' => stdClass Object &{<span class="php-variable">$bhash</span>} ()
         'inf' => null
     )
-    '{<span class="php-variable">$bhash</span>}' => Array &0
 )

EOF
,
    );
  }
  else {
    $data[] = array(
      $storage1,
      $storage2,
      <<<EOF
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
-SplObjectStorage Object &{<span class="php-variable">$storage1hash</span>} (
-    '{<span class="php-variable">$ahash</span>}' => Array &0 (
-        'obj' => stdClass Object &{<span class="php-variable">$ahash</span>} (
-            'foo' => 'bar'
-        )
-        'inf' => null
-    )
-    '{<span class="php-variable">$bhash</span>}' => Array &1 (
+SplObjectStorage Object &{<span class="php-variable">$storage2hash</span>} (
+    '{<span class="php-variable">$bhash</span>}' => Array &0 (
         'obj' => stdClass Object &{<span class="php-variable">$bhash</span>} ()
         'inf' => null
     )
 )

EOF
,
    );
  }
  return $data;
}