I wants to create the unit test for this observer class. I tried diff-2 ways but didn't get any help. Can anyone create the unit test for this it would be helpful
<?php
declare(strict_types=1);
namespace VendorName\ModuleName\Observer;
use VendorName\ModuleName\Helper\Connection as SFMCHelper;
use VendorName\ModuleName\Helper\Queue as QueueHelper;
use Magento\Framework\Event\Manager;
use Magento\Framework\Event\ObserverInterface;
class CustomerSaveAfterObserver implements ObserverInterface
{
/**
* @var QueueHelper
*/
protected QueueHelper $queueHelper;
/**
* @var SFMCHelper
*/
protected SFMCHelper $sfmcHelper;
/**
* @param SFMCHelper $sfmcHelper
* @param QueueHelper $queueHelper
*/
public function __construct(
SFMCHelper $sfmcHelper,
QueueHelper $queueHelper
) {
$this->sfmcHelper = $sfmcHelper;
$this->queueHelper = $queueHelper;
}
/**
* Customer save after event handler
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$customerId = $observer->getCustomerDataObject()->getId();
if ($customerId && $this->sfmcHelper->isAutoSyncEnabled()) {
$this->queueHelper->publishSFMCMessage($customerId, QueueHelper::SFMC_EVENT_CUSTOMER_UPDATE);
}
}
}
Thanks in Advance