DigestManagerTest.php in Message Digest 8
File
tests/src/Kernel/DigestManagerTest.php
View source
<?php
namespace Drupal\Tests\message_digest\Kernel;
class DigestManagerTest extends DigestTestBase {
public function testProcessDigests() {
$this
->assertEquals(0, $this->container
->get('state')
->get('message_digest:weekly_last_run', 0));
$expected = $this->container
->get('datetime.time')
->getRequestTime();
$this->container
->get('cron')
->run();
$last_run = $this->container
->get('state')
->get('message_digest:weekly_last_run', 0);
$this
->assertEquals($expected, $last_run);
$this->container
->get('request_stack')
->getCurrentRequest()->server
->set('REQUEST_TIME', $expected + 60);
$this->container
->get('cron')
->run();
$this
->assertEquals($expected, $this->container
->get('state')
->get('message_digest:weekly_last_run', 0));
$this->container
->get('request_stack')
->getCurrentRequest()->server
->set('REQUEST_TIME', $expected + 60 * 60 * 24 * 8);
$expected = $this->container
->get('datetime.time')
->getRequestTime();
$this->container
->get('cron')
->run();
$this
->assertEquals($expected, $this->container
->get('state')
->get('message_digest:weekly_last_run', 0));
}
}