Contao\CoreBundle\EventListener\CommandSchedulerListener::onKernelTerminate PHP Method

onKernelTerminate() public method

Runs the command scheduler.
public onKernelTerminate ( )
    public function onKernelTerminate()
    {
        if (!$this->framework->isInitialized() || !$this->canRunController()) {
            return;
        }
        /** @var FrontendCron $controller */
        $controller = $this->framework->createInstance('Contao\\FrontendCron');
        $controller->run();
    }

Usage Example

 /**
  * Tests that the listener does nothing if the command scheduler has been disabled.
  *
  * @runInSeparateProcess
  * @preserveGlobalState disabled
  */
 public function testDisableCron()
 {
     $adapter = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\Adapter')->setMethods(['get'])->disableOriginalConstructor()->getMock();
     $adapter->expects($this->any())->method('get')->willReturn(true);
     $this->framework = $this->getMockBuilder('Contao\\CoreBundle\\Framework\\ContaoFramework')->disableOriginalConstructor()->getMock();
     $this->framework->expects($this->any())->method('getAdapter')->willReturn($adapter);
     $this->framework->expects($this->any())->method('isInitialized')->willReturn(true);
     $listener = new CommandSchedulerListener($this->framework);
     $listener->onKernelTerminate();
 }