44 $this->collectionFactoryMock =
45 $this->createPartialMock(\
Magento\Store\Model\
ResourceModel\Website\CollectionFactory::class, [
'create']);
46 $this->sessionFactoryMock = $this->createPartialMock(
47 \
Magento\Persistent\Model\SessionFactory::class,
50 $this->scheduleMock = $this->createMock(\
Magento\Cron\Model\Schedule::class);
51 $this->sessionMock = $this->createMock(\
Magento\Persistent\Model\Session::class);
52 $this->websiteCollectionMock
55 $this->model = new \Magento\Persistent\Observer\ClearExpiredCronJobObserver(
56 $this->collectionFactoryMock,
57 $this->sessionFactoryMock
63 $this->collectionFactoryMock
64 ->expects($this->once())
66 ->will($this->returnValue($this->websiteCollectionMock));
67 $this->websiteCollectionMock->expects($this->once())->method(
'getAllIds')->will($this->returnValue([1]));
68 $this->sessionFactoryMock
69 ->expects($this->once())
71 ->will($this->returnValue($this->sessionMock));
72 $this->sessionMock->expects($this->once())->method(
'deleteExpired')->with(1);
73 $this->model->execute($this->scheduleMock);
78 $this->collectionFactoryMock
79 ->expects($this->once())
81 ->will($this->returnValue($this->websiteCollectionMock));
82 $this->websiteCollectionMock->expects($this->once())->method(
'getAllIds');
83 $this->sessionFactoryMock
84 ->expects($this->never())
86 $this->model->execute($this->scheduleMock);
testExecuteForNotExistingWebsite()