Skip to content

Commit

Permalink
Roll some tests where multiple embargoes are involved.
Browse files Browse the repository at this point in the history
Other embargoes block access (but exemptions from _any_ are let through).
  • Loading branch information
adam-vessey committed Mar 9, 2024
1 parent 19abd03 commit be8a746
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions tests/src/Kernel/EmbargoAccessQueryTaggingAlterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function testDeletedNodeEmbargoFileAccessQueryAlterAccessAllowed() {
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testPublishScheduledEmbargoAccess() {
// Create an embargo scheduled to be unpublished in the future.
// Create an embargo scheduled to be published in the future.
$this->setEmbargoFutureUnpublishDate($this->embargo);

$result = $this->generateNodeSelectAccessQuery($this->user)->execute()->fetchAll();
Expand All @@ -243,7 +243,7 @@ public function testPublishScheduledEmbargoAccess() {
}

/**
* Tests embargo scheduled to be unpublished in the past.
* Test embargo scheduled in the past, without any other embargo.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
Expand All @@ -260,4 +260,46 @@ public function testUnpublishScheduledEmbargoAccess() {
$this->assertContains($this->unassociatedNode->id(), $ids, 'contains unassociated node');
}

/**
* Test embargo scheduled in the past with another relevant scheduled embargo.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testUnpublishScheduledWithPublishedEmbargoAccess() {
$this->embargo->setExpirationType(EmbargoInterface::EXPIRATION_TYPE_SCHEDULED)->save();
// Create an embargo scheduled to be unpublished in the future.
$this->setEmbargoPastUnpublishDate($this->embargo);

$embargo = $this->createEmbargo($this->embargoedNode);
$embargo->setExpirationType(EmbargoInterface::EXPIRATION_TYPE_SCHEDULED)->save();
$this->setEmbargoFutureUnpublishDate($embargo);

$result = $this->generateNodeSelectAccessQuery($this->user)->execute()->fetchAll();

$ids = array_column($result, 'nid');
$this->assertNotContains($this->embargoedNode->id(), $ids, 'does not contain node with expired embargo having other schedule embargo in future');
$this->assertContains($this->unembargoedNode->id(), $ids, 'contains unembargoed node');
$this->assertContains($this->unassociatedNode->id(), $ids, 'contains unassociated node');
}

/**
* Test embargo scheduled in the past, but with a separate indefinite embargo.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
public function testUnpublishScheduledWithIndefiniteEmbargoAccess() {
$this->embargo->setExpirationType(EmbargoInterface::EXPIRATION_TYPE_SCHEDULED)->save();
// Create an embargo scheduled to be unpublished in the future.
$this->setEmbargoPastUnpublishDate($this->embargo);

$this->createEmbargo($this->embargoedNode);

$result = $this->generateNodeSelectAccessQuery($this->user)->execute()->fetchAll();

$ids = array_column($result, 'nid');
$this->assertNotContains($this->embargoedNode->id(), $ids, 'does not contain node with expired embargo having other indefinite embargo');
$this->assertContains($this->unembargoedNode->id(), $ids, 'contains unembargoed node');
$this->assertContains($this->unassociatedNode->id(), $ids, 'contains unassociated node');
}

}

0 comments on commit be8a746

Please sign in to comment.