public function RePublishDependencyChangesTest::testIsAlreadyEnqueued in Acquia Content Hub 8.2
Tests that node isn't enqueued more than once.
File
- tests/
src/ Kernel/ RePublishDependencyChangesTest.php, line 99
Class
- RePublishDependencyChangesTest
- Tests that entities whose depcalc cache got invalidated are republished.
Namespace
Drupal\Tests\acquia_contenthub\KernelCode
public function testIsAlreadyEnqueued() {
$user = $this
->setUpCurrentUser();
// Creates a new node with taxonomy reference.
/** @var \Drupal\node\NodeInterface $node */
$node = Node::create([
'type' => 'bundle_test',
'uid' => $user
->id(),
'taxonomy_reference' => $this->term
->id(),
'title' => 'Title',
]);
$node
->setPublished();
$node
->save();
// Create path alias entity for the given node.
$path = PathAlias::create([
'path' => '/node/' . $node
->id(),
'alias' => 'new_test_path',
]);
$path
->save();
$publisher_tracker = \Drupal::service('acquia_contenthub_publisher.tracker');
$this
->assertNotFalse($publisher_tracker
->getQueueId($node
->uuid()), 'Node queued for export');
$this
->assertNotFalse($publisher_tracker
->getQueueId($path
->uuid()), 'Path alias queued for export');
$this
->assertNotFalse($publisher_tracker
->getQueueId($this->term
->uuid()), 'Term queued for export');
$this->contentHubQueue
->purgeQueues();
$wrapper = new DependentEntityWrapper($node);
$stack = new DependencyStack();
$calculator = \Drupal::service('entity.dependency.calculator');
$calculator
->calculateDependencies($wrapper, $stack);
$this->term
->delete();
$this
->assertNotFalse($publisher_tracker
->getQueueId($node
->uuid()), 'Node queued again after term reference delete');
$this
->assertNotFalse($publisher_tracker
->getQueueId($path
->uuid()), 'Path queued again after term reference delete');
$this
->assertFalse($publisher_tracker
->getQueueId($this->term
->uuid()), 'Term not queued for export anymore');
}