You are here

public function CliTest::testPullUpdate in Entity Share 8.2

Test pull command with the update option.

File

modules/entity_share_client/tests/src/Functional/CliTest.php, line 98

Class

CliTest
General functional test class for CLI integration.

Namespace

Drupal\Tests\entity_share_client\Functional

Code

public function testPullUpdate() {
  $channel_infos = $this->remoteManager
    ->getChannelsInfos($this->remote);
  $channel_info = array_shift($channel_infos);
  $channel_url = $channel_info['url'];
  $channel_url_uuid = $channel_info['url_uuid'];
  $update_count = $this->cliService
    ->pullUpdates($this->remote, $channel_url, $channel_url_uuid, 'node');
  $this->jsonapiHelper
    ->clearImportedEntities();
  $this
    ->assertEquals(2, $update_count, 'On the first run, the two contents had been pulled.');
  $this
    ->checkCreatedEntities();
  $update_count = $this->cliService
    ->pullUpdates($this->remote, $channel_url, $channel_url_uuid, 'node');
  $this->jsonapiHelper
    ->clearImportedEntities();
  $this
    ->assertEquals(0, $update_count, 'On the second run, no content had been pulled.');

  // Edit the first content (also this emulates a change on the client
  // website).
  $node = $this
    ->loadEntity('node', 'es_test_1');
  $node
    ->set('title', $this
    ->randomString());
  $node
    ->setChangedTime($this->faker
    ->unixTime());
  $node
    ->save();
  $update_count = $this->cliService
    ->pullUpdates($this->remote, $channel_url, $channel_url_uuid, 'node');
  $this->jsonapiHelper
    ->clearImportedEntities();
  $this
    ->assertEquals(1, $update_count, 'On the third run, only the changed content had been pulled.');
  $this
    ->checkCreatedEntities();
  $update_count = $this->cliService
    ->pullUpdates($this->remote, $channel_url, $channel_url_uuid, 'node');
  $this->jsonapiHelper
    ->clearImportedEntities();
  $this
    ->assertEquals(0, $update_count, 'On the fourth run, no content had been pulled.');
}