collectionFactory = $this->createPartialMock( \Magento\Cms\Model\ResourceModel\Block\CollectionFactory::class, ['create'] ); $this->block = $objectManager->getObject( \Magento\Cms\Model\Config\Source\Block::class, [ 'collectionFactory' => $this->collectionFactory, ] ); } /** * Run test toOptionArray method * * @return void */ public function testToOptionArray() { $blockCollectionMock = $this->createMock(\Magento\Cms\Model\ResourceModel\Block\Collection::class); $this->collectionFactory->expects($this->once()) ->method('create') ->will($this->returnValue($blockCollectionMock)); $blockCollectionMock->expects($this->once()) ->method('toOptionIdArray') ->will($this->returnValue('return-value')); $this->assertEquals('return-value', $this->block->toOptionArray()); } }