You are here

protected function TestBase::assertIdenticalObject in SimpleTest 8.3

Checks to see if two objects are identical.

Parameters

object $object1: The first object to check.

object $object2: The second object to check.

$message: (optional) A message to display with the assertion. Do not translate messages: use \Drupal\Component\Render\FormattableMarkup to embed variables in the message text, not t(). If left blank, a default message will be displayed.

$group: (optional) The group this message is in, which is displayed in a column in test output. Use 'Debug' to indicate this is debugging output. Do not translate this string. Defaults to 'Other'; most tests do not override this default.

Return value

TRUE if the assertion succeeded, FALSE otherwise.

File

src/TestBase.php, line 713

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

protected function assertIdenticalObject($object1, $object2, $message = '', $group = 'Other') {
  $message = $message ?: new FormattableMarkup('@object1 is identical to @object2', [
    '@object1' => var_export($object1, TRUE),
    '@object2' => var_export($object2, TRUE),
  ]);
  $identical = TRUE;
  foreach ($object1 as $key => $value) {
    $identical = $identical && isset($object2->{$key}) && $object2->{$key} === $value;
  }
  return $this
    ->assertTrue($identical, $message, $group);
}