9 use \Magento\Framework\App\Cron;
11 class CronTest extends \PHPUnit\Framework\TestCase
41 private $objectManager;
45 $this->_stateMock = $this->createMock(\
Magento\Framework\
App\State::class);
46 $this->_request = $this->createMock(\
Magento\Framework\
App\Console\Request::class);
47 $this->_responseMock = $this->createMock(\
Magento\Framework\
App\Console\Response::class);
48 $this->objectManager = $this->getMockForAbstractClass(\
Magento\Framework\ObjectManagerInterface::class);
49 $this->_model =
new Cron(
64 $areaMock = $this->createMock(\
Magento\Framework\
App\Area::class);
65 $areaMock->expects($this->once())
69 $areaListMock = $this->createMock(\
Magento\Framework\
App\AreaList::class);
70 $areaListMock->expects($this->any())
73 ->willReturn($areaMock);
80 $configLoader = $this->getMockForAbstractClass(\
Magento\Framework\
ObjectManager\ConfigLoaderInterface::class);
81 $eventManagerMock = $this->createMock(\
Magento\Framework\
Event\ManagerInterface::class);
83 $this->objectManager->expects($this->any())
85 ->will($this->returnValueMap([
87 [\
Magento\Framework\
Event\ManagerInterface::class, $eventManagerMock]
89 $crontabConfig = [
'config'];
90 $configLoader->expects($this->once())
93 ->willReturn($crontabConfig);
94 $this->objectManager->expects($this->once())
96 ->with($crontabConfig);
97 $this->_stateMock->expects($this->once())->method(
'setAreaCode')->with(
Area::AREA_CRONTAB);
98 $eventManagerMock->expects($this->once())->method(
'dispatch')->with(
'default');
99 $this->_responseMock->expects($this->once())->method(
'setCode')->with(0);
100 $this->assertEquals($this->_responseMock, $this->_model->launch());
testLaunchDispatchesCronEvent()