collectionFactoryMock = $this->createPartialMock( CollectionFactory::class, ['create'] ); $this->model = $objectManager->getObject( Observer::class, [ 'queueCollectionFactory' => $this->collectionFactoryMock ] ); } /** * Test scheduledSend() method */ public function testScheduledSend() { $collectionMock = $this->createMock(Collection::class); $this->collectionFactoryMock->expects($this->once())->method('create')->willReturn($collectionMock); $collectionMock->expects($this->once())->method('setPageSize')->with(3)->willReturnSelf(); $collectionMock->expects($this->once())->method('setCurPage')->with(1)->willReturnSelf(); $collectionMock->expects($this->once())->method('addOnlyForSendingFilter')->willReturnSelf(); $collectionMock->expects($this->once())->method('load')->willReturnSelf(); $collectionMock->expects($this->once())->method('walk')->with('sendPerSubscriber', [20]); $this->model->scheduledSend(); } }