You are here

public function ImportUpdateAssetsTest::testOnHandleWebhookWithAutoUpdateDisabledEntityStatus in Acquia Content Hub 8.2

@covers ::onHandleWebhook

Throws

\Exception

File

tests/src/Kernel/ImportUpdateAssetsTest.php, line 90

Class

ImportUpdateAssetsTest
@coversDefaultClass \Drupal\acquia_contenthub_subscriber\EventSubscriber\HandleWebhook\ImportUpdateAssets

Namespace

Drupal\Tests\acquia_contenthub\Kernel

Code

public function testOnHandleWebhookWithAutoUpdateDisabledEntityStatus() {
  $uuid = '00000000-0003-460b-ac74-b6bed08b4441';
  $this->subTracker
    ->queue($uuid);
  $this->subTracker
    ->setStatusByUuid($uuid, $this->subTracker::AUTO_UPDATE_DISABLED);
  $request = Request::createFromGlobals();
  $key = new Key('id', 'secret');
  $payload = [
    'status' => 'successful',
    'crud' => 'update',
    'assets' => [
      [
        'uuid' => $uuid,
        'type' => 'drupal8_content_entity',
      ],
    ],
    'initiator' => $uuid,
  ];
  $this
    ->createAcquiaContentHubAdminSettings();
  $client_factory = $this->container
    ->get('acquia_contenthub.client.factory');
  $event = new HandleWebhookEvent($request, $payload, $key, $client_factory
    ->getClient());
  $this
    ->assertEmpty($this->loggerChannel
    ->getLogMessages());
  $this->importUpdateAssets
    ->onHandleWebhook($event);
  $log_messages = $this->loggerChannel
    ->getLogMessages();
  $this
    ->assertNotEmpty($log_messages);

  // Assert there are info in log messages.
  $this
    ->assertNotEmpty($log_messages[RfcLogLevel::INFO]);

  // Assert first message in info.
  $this
    ->assertEquals('Entity with UUID 00000000-0003-460b-ac74-b6bed08b4441 was not added to the import queue because it has auto update disabled.', $log_messages[RfcLogLevel::INFO][0]);
}