PreviewLinkExpiryTest.php in Preview Link 8
File
tests/src/Kernel/PreviewLinkExpiryTest.php
View source
<?php
namespace Drupal\Tests\preview_link\Kernel;
use Drupal\preview_link\Entity\PreviewLink;
class PreviewLinkExpiryTest extends PreviewLinkBase {
protected $node;
public function setUp() {
parent::setUp();
$this->node = $this
->createNode();
}
public function testPreviewLinkExpires() {
$days = \Drupal::state()
->get('preview_link_expiry_days', 7);
$days = $days + 1;
$days_in_seconds = $days * 86400;
$expired_preview_link = PreviewLink::create([
'entity_type_id' => 'node',
'entity_id' => $this->node
->id(),
'generated_timestamp' => $days_in_seconds,
]);
$expired_preview_link
->save();
$id = $expired_preview_link
->id();
preview_link_cron();
$this
->assertNull($this->storage
->load($id));
}
}