You are here

public function ImportEntityManagerTest::testEntityPresaveEntityIsDependent in Acquia Content Hub 8

Tests the entityPresave() method, the entity is dependent.

@covers ::entityPresave

File

tests/src/Unit/ImportEntityManagerTest.php, line 276

Class

ImportEntityManagerTest
PHPUnit test for the ImportEntityManager class.

Namespace

Drupal\Tests\acquia_contenthub\Unit

Code

public function testEntityPresaveEntityIsDependent() {
  $original_paragraph = $this
    ->createMock('\\Drupal\\paragraphs\\ParagraphInterface');
  $parent_paragraph = $this
    ->createMock('\\Drupal\\paragraphs\\ParagraphInterface');
  $paragraph = $this
    ->createMock('\\Drupal\\paragraphs\\ParagraphInterface');
  $paragraph->original = $original_paragraph;
  $paragraph
    ->expects($this
    ->exactly(2))
    ->method('getEntityTypeId')
    ->willReturn('paragraph');
  $paragraph
    ->expects($this
    ->once())
    ->method('id')
    ->willReturn(12);
  $paragraph
    ->expects($this
    ->once())
    ->method('getParentEntity')
    ->willReturn($parent_paragraph);
  $parent_paragraph
    ->expects($this
    ->once())
    ->method('getEntityTypeId')
    ->willReturn('paragraph');
  $parent_paragraph
    ->expects($this
    ->once())
    ->method('id')
    ->willReturn(13);
  $this->contentHubEntitiesTracking
    ->expects($this
    ->at(0))
    ->method('loadImportedByDrupalEntity')
    ->with('paragraph', 12)
    ->willReturn($this->contentHubEntitiesTracking);
  $this->contentHubEntitiesTracking
    ->expects($this
    ->at(1))
    ->method('isDependent')
    ->willReturn(TRUE);
  $this->contentHubEntitiesTracking
    ->expects($this
    ->at(2))
    ->method('loadImportedByDrupalEntity')
    ->with('paragraph', 13)
    ->willReturn(NULL);
  $this->diffEntityComparison
    ->expects($this
    ->never())
    ->method('compareRevisions');
  $this->importEntityManager
    ->entityPresave($paragraph);
}