Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html/strat/web/core/tests/Drupal/KernelTests/Core/Entity/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/html/strat/web/core/tests/Drupal/KernelTests/Core/Entity/ContentEntityHasChangesTest.php

<?php

declare(strict_types=1);

namespace Drupal\KernelTests\Core\Entity;

use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;

/**
 * Tests ContentEntityBase::hasTranslationChanges().
 *
 * @group Entity
 */
class ContentEntityHasChangesTest extends KernelTestBase {

  /**
   * Bundle of entity.
   *
   * @var string
   */
  protected $bundle = 'test';

  /**
   * {@inheritdoc}
   */
  protected static $modules = ['system', 'user', 'entity_test'];

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();

    $this->installEntitySchema('user');
    $this->installEntitySchema('entity_test_mulrev_changed_rev');
  }

  /**
   * Tests the correct functionality of the hasTranslationChanges() function.
   */
  public function testHasTranslationChanges(): void {
    $user1 = User::create([
      'name' => 'username1',
      'status' => 1,
    ]);
    $user1->save();

    $user2 = User::create([
      'name' => 'username2',
      'status' => 1,
    ]);
    $user2->save();

    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
    $storage = $this->container->get('entity_type.manager')
      ->getStorage('entity_test_mulrev_changed_rev');
    /** @var \Drupal\entity_test\Entity\EntityTestMulRevChangedWithRevisionLog $entity */
    $entity = $storage->create([
      'name' => $this->randomString(),
    ]);
    $entity->setRevisionUserId($user1->id());
    $entity->save();

    $this->assertFalse($entity->hasTranslationChanges(), 'ContentEntityBase::hasTranslationChanges() found no changes after the entity has been saved.');

    // Update the revision metadata fields and the changed field, which should
    // be skipped from checking for changes in
    // ContentEntityBase::hasTranslationChanges().
    $entity_previous_rev_id = $entity->getRevisionId();
    // Revision metadata field revision_timestamp.
    $entity->setRevisionCreationTime(time() + 1);
    // Revision metadata field revision_uid.
    $entity->setRevisionUserId($user2->id());
    // Revision metadata field revision_log.
    $entity->setRevisionLogMessage('test');
    // Revision metadata field revision_translation_affected.
    $entity->setRevisionTranslationAffected(TRUE);
    // Changed field.
    $entity->setChangedTime(time() + 1);

    // Check that the revision metadata fields and the changed field have been
    // skipped when comparing same revisions.
    $this->assertFalse($entity->hasTranslationChanges(), 'ContentEntityBase::hasTranslationChanges() found no changes when comparing different revisions.');

    // Check that the revision metadata fields and the changed field have been
    // skipped when comparing same revisions with enforced new revision to be
    // created on save.
    $entity->setNewRevision(TRUE);
    $this->assertFalse($entity->hasTranslationChanges(), 'ContentEntityBase::hasTranslationChanges() found no changes when comparing different revisions.');

    // Save the entity in new revision with changes on the revision metadata
    // fields.
    $entity->save();

    // Check that the revision metadata fields and the changed field have been
    // skipped when comparing different revisions.
    $entity = $storage->loadRevision($entity_previous_rev_id);
    $this->assertFalse($entity->hasTranslationChanges(), 'ContentEntityBase::hasTranslationChanges() found no changes when comparing different revisions.');
  }

}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net