66 $this->eventDispatcher = $this->getMockBuilder(\
Magento\Framework\Event\ManagerInterface::class)
67 ->disableOriginalConstructor()
68 ->setMethods([
'dispatch'])
70 $this->eventDispatcher->method(
'dispatch')->willReturnSelf();
71 $this->context = $this->getMockBuilder(\
Magento\Framework\Model\Context::class)
72 ->disableOriginalConstructor()
73 ->setMethods([
'getEventDispatcher'])
75 $this->context->method(
'getEventDispatcher')->willReturn($this->eventDispatcher);
77 $this->registry = $this->createMock(\
Magento\Framework\Registry::class);
78 $this->config = $this->createMock(\
Magento\Framework\
App\
Config\ScopeConfigInterface::class);
79 $this->cacheTypeList = $this->getMockBuilder(\
Magento\Framework\
App\
Cache\TypeList::class)
80 ->disableOriginalConstructor()
81 ->setMethods([
'invalidate'])
85 ->disableOriginalConstructor()
87 $this->storeManager = $this->getMockBuilder(\
Magento\
Store\Model\StoreManager::class)
88 ->disableOriginalConstructor()
89 ->setMethods([
'getStores'])
91 $this->storeManager->method(
'getStores')->willReturn([]);
93 $this->appResource =$this->getMockBuilder(\
Magento\Framework\
App\ResourceConnection::class)
94 ->disableOriginalConstructor()
96 $this->urlFinder =$this->getMockBuilder(\
Magento\
UrlRewrite\Model\UrlFinderInterface::class)
97 ->setMethods([
'findAllByData',
'findOneByData'])
99 $this->urlFinder->method(
'findAllByData')->willReturn([]);
101 $this->suffixModel = new \Magento\Catalog\Model\System\Config\Backend\Catalog\Url\Rewrite\Suffix(
105 $this->cacheTypeList,
106 $this->urlRewriteHelper,
115 $this->suffixModel->setValue(
'new');
116 $this->suffixModel->setPath(
117 \
Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX
119 $this->cacheTypeList->expects($this->exactly(2))->method(
'invalidate')->withConsecutive(
124 [$this->equalTo(
'config')]
126 $this->suffixModel->afterSave();
131 $this->suffixModel->setValue(
'');
132 $this->suffixModel->setPath(
133 \
Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX
135 $this->cacheTypeList->expects($this->never())->method(
'invalidate');
136 $this->suffixModel->afterSave();
141 $this->suffixModel->setValue(
'new');
142 $this->suffixModel->setPath(
143 \
Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX
145 $this->cacheTypeList->expects($this->once())->method(
'invalidate')->with(
'config');
146 $this->suffixModel->afterSave();
testAfterSaveWithoutChanges()
testAfterSaveCleanCache()