public function HookCronTest::testRecentExecution in Entity Share Cron 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/HookCronTest.php \Drupal\Tests\entity_share_cron\Kernel\HookCronTest::testRecentExecution()
Tests if no channels are enqueuend when the interval has not elapsed.
File
- tests/
src/ Kernel/ HookCronTest.php, line 168
Class
- HookCronTest
- Tests the hook_cron() implementation.
Namespace
Drupal\Tests\entity_share_cron\KernelCode
public function testRecentExecution() {
// Adjusts configuration as though a recent synchronization happened.
$last_run = time();
$this->config
->set('cron_interval', 9999999);
$this->state
->set('entity_share_cron.cron_last_run', $last_run);
// Configure some remotes and channels.
$this->config
->set('remotes', [
'remote1' => [
'enabled' => TRUE,
'channels' => [
'channel1' => [
'enabled' => TRUE,
'url' => 'url1',
],
],
],
]);
// Saves changes to configuration.
$this->config
->save();
// Invokes the hook.
\entity_share_cron_cron();
// Checks if the queue is empty.
$this
->assertEquals(0, $this->queue
->numberOfItems());
$this
->assertEquals($last_run, $this->state
->get('entity_share_cron.cron_last_run'));
}