protected function TestBase::assertIdenticalObject

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 format_string() 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.

4 calls to TestBase::assertIdenticalObject()
DatabaseStorageExpirableTest::testCRUDWithExpiration in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/DatabaseStorageExpirableTest.php
Tests CRUD functionality with expiration.
StorageTestBase::testCRUD in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php
Tests CRUD operations.
StorageTestBase::testSetIfNotExists in drupal/core/modules/system/lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php
Tests the setIfNotExists() method.
TempStoreDatabaseTest::testUserTempStore in drupal/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php
Tests the UserTempStore API.

File

drupal/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php, line 522
Definition of Drupal\simpletest\TestBase.

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

protected function assertIdenticalObject($object1, $object2, $message = '', $group = 'Other') {
  $message = $message ?: format_string('!object1 is identical to !object2', array(
    '!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);
}