You are here

protected function TestBase::assertIdenticalObject in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/TestBase.php \Drupal\simpletest\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 \Drupal\Component\Utility\SafeMarkup::format() 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 core/modules/system/src/Tests/KeyValueStore/DatabaseStorageExpirableTest.php
Tests CRUD functionality with expiration.
StorageTestBase::testCRUD in core/modules/system/src/Tests/KeyValueStore/StorageTestBase.php
Tests CRUD operations.
StorageTestBase::testSetIfNotExists in core/modules/system/src/Tests/KeyValueStore/StorageTestBase.php
Tests the setIfNotExists() method.
TempStoreDatabaseTest::testUserTempStore in core/modules/user/src/Tests/TempStoreDatabaseTest.php
Tests the UserTempStore API.

File

core/modules/simpletest/src/TestBase.php, line 806
Contains \Drupal\simpletest\TestBase.

Class

TestBase
Base class for Drupal tests.

Namespace

Drupal\simpletest

Code

protected function assertIdenticalObject($object1, $object2, $message = '', $group = 'Other') {
  $message = $message ?: SafeMarkup::format('@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);
}