public function HookCronTest::testNoRemotesEnabled 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::testNoRemotesEnabled()
Tests when no remotes are enabled.
File
- tests/
src/ Kernel/ HookCronTest.php, line 130
Class
- HookCronTest
- Tests the hook_cron() implementation.
Namespace
Drupal\Tests\entity_share_cron\KernelCode
public function testNoRemotesEnabled() {
// Adjusts configuration to force a synchronization.
$this->config
->set('cron_interval', 1);
$this->state
->set('entity_share_cron.cron_last_run', -999999);
// Configure some remotes and channels.
$this->config
->set('remotes', [
'remote1' => [
'enabled' => FALSE,
'channels' => [
'channel1' => [
'enabled' => FALSE,
'url' => 'url1',
],
],
],
'remote2' => [
'enabled' => FALSE,
],
]);
// 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());
$last_run = $this->state
->get('entity_share_cron.cron_last_run') ? $this->state
->get('entity_share_cron.cron_last_run') : -99999;
$this
->assertGreaterThan(-99999, $last_run);
$this
->assertLessThanOrEqual(time(), $last_run);
}