You are here

public function EntityFormTest::testGetFormEntityFormNodeIsImported in Acquia Content Hub 8

Tests the getForm() method, node is imported.

@covers ::getForm

@dataProvider providerTestGetFormEntityFormNodeIsImported

Parameters

bool $has_local_change: Has local change flag.

bool $is_auto_update: Is auto update flag.

string $has_local_change_text: "Has local change" text.

File

tests/src/Unit/Form/EntityFormTest.php, line 110

Class

EntityFormTest
PHPUnit test for the EntityForm class.

Namespace

Drupal\Tests\acquia_contenthub\Unit\Form

Code

public function testGetFormEntityFormNodeIsImported($has_local_change, $is_auto_update, $has_local_change_text) {
  $node = $this
    ->createMock('\\Drupal\\node\\NodeInterface');
  $node
    ->expects($this
    ->once())
    ->method('id')
    ->willReturn(12);
  $node
    ->expects($this
    ->once())
    ->method('getEntityTypeId')
    ->willReturn('node');
  $this->contentHubEntitiesTracking
    ->expects($this
    ->once())
    ->method('loadImportedByDrupalEntity')
    ->with('node', 12)
    ->willReturn($this->contentHubEntitiesTracking);
  $this->currentUser
    ->expects($this
    ->once())
    ->method('hasPermission')
    ->with('administer acquia content hub')
    ->willReturn(TRUE);
  $this->contentHubEntitiesTracking
    ->expects($this
    ->once())
    ->method('hasLocalChange')
    ->willReturn($has_local_change);
  $this->contentHubEntitiesTracking
    ->expects($this
    ->once())
    ->method('isAutoUpdate')
    ->willReturn($is_auto_update);
  $this->entityForm
    ->setStringTranslation($this
    ->getStringTranslationStub());
  $form = $this->entityForm
    ->getForm($node);
  $this
    ->assertEquals($has_local_change_text, $form['auto_update_label']['#markup']);
  $this
    ->assertTrue($has_local_change === isset($form['auto_update_local_changes_label']));
}