diff --git a/Model/Config/ConfigReaderInterface.php b/Model/Config/ConfigReaderInterface.php
new file mode 100644
index 0000000..e156eb7
--- /dev/null
+++ b/Model/Config/ConfigReaderInterface.php
@@ -0,0 +1,85 @@
+aligentSitemapConfig->isPwaPagesInclude((int)$storeId)) {
- $pwaPagesUrlKeys = $this->aligentSitemapConfig->getPwaPagesUrlKey((int)$storeId);
+ if ($this->aligentSitemapConfigReaderInterface->isPwaPagesInclude((int)$storeId)) {
+ $pwaPagesUrlKeys = $this->aligentSitemapConfigReaderInterface->getPwaPagesUrlKey((int)$storeId);
foreach ($pwaPagesUrlKeys as $pwaPagesUrlKey) {
$items[] = $this->itemFactory->create([
'url' => $pwaPagesUrlKey,
diff --git a/Model/Sitemap.php b/Model/Sitemap.php
index 36c586f..eaab816 100644
--- a/Model/Sitemap.php
+++ b/Model/Sitemap.php
@@ -29,7 +29,7 @@
use Magento\Sitemap\Model\SitemapItemInterfaceFactory;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Sitemap\Helper\Data as SitemapHelper;
-use Aligent\Sitemap\Model\Config\Data as AligentSitemapConfig;
+use Aligent\Sitemap\Model\Config\ConfigReaderInterface as AligentSitemapConfigReaderInterface;
class Sitemap extends MagentoSitemap
{
@@ -46,7 +46,7 @@ class Sitemap extends MagentoSitemap
* @param StoreManagerInterface $storeManager
* @param RequestInterface $request
* @param DateTime $dateTime
- * @param AligentSitemapConfig $aligentSitemapConfig
+ * @param AligentSitemapConfigReaderInterface $aligentSitemapConfig
* @param AbstractResource|null $resource
* @param AbstractDb|null $resourceCollection
* @param array $data
@@ -68,7 +68,7 @@ public function __construct(
StoreManagerInterface $storeManager,
RequestInterface $request,
DateTime $dateTime,
- private readonly AligentSitemapConfig $aligentSitemapConfig,
+ private readonly AligentSitemapConfigReaderInterface $aligentSitemapConfig,
AbstractResource $resource = null,
AbstractDb $resourceCollection = null,
array $data = [],
diff --git a/Plugin/Model/ResourceModel/Catalog/GetValidCategoryPagesForSitemap.php b/Plugin/Model/ResourceModel/Catalog/GetValidCategoryPagesForSitemap.php
index fd57b2f..02f24cc 100644
--- a/Plugin/Model/ResourceModel/Catalog/GetValidCategoryPagesForSitemap.php
+++ b/Plugin/Model/ResourceModel/Catalog/GetValidCategoryPagesForSitemap.php
@@ -17,7 +17,7 @@
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Catalog\Model\ResourceModel\Category as CategoryResource;
-use Aligent\Sitemap\Model\Config\Data as AligentSitemapConfig;
+use Aligent\Sitemap\Model\Config\ConfigReaderInterface as AligentSitemapConfigReaderInterface;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\DataObject;
@@ -31,13 +31,13 @@ class GetValidCategoryPagesForSitemap
private $_attributesCache = [];
/**
- * @param AligentSitemapConfig $aligentSitemapConfig
+ * @param AligentSitemapConfigReaderInterface $aligentSitemapConfig
* @param StoreManagerInterface $storeManager
* @param CategoryResource $categoryResource
* @param MetadataPool $metadataPool
*/
public function __construct(
- private readonly AligentSitemapConfig $aligentSitemapConfig,
+ private readonly AligentSitemapConfigReaderInterface $aligentSitemapConfig,
private readonly StoreManagerInterface $storeManager,
private readonly CategoryResource $categoryResource,
private readonly MetadataPool $metadataPool
diff --git a/Plugin/Model/ResourceModel/Catalog/GetValidProductPagesForSitemap.php b/Plugin/Model/ResourceModel/Catalog/GetValidProductPagesForSitemap.php
index 21801a4..472ef05 100644
--- a/Plugin/Model/ResourceModel/Catalog/GetValidProductPagesForSitemap.php
+++ b/Plugin/Model/ResourceModel/Catalog/GetValidProductPagesForSitemap.php
@@ -24,7 +24,7 @@
use Magento\Store\Model\Store;
use Magento\Store\Model\StoreManagerInterface;
use Zend_Db_Statement_Exception;
-use Aligent\Sitemap\Model\Config\Data as AligentSitemapConfig;
+use Aligent\Sitemap\Model\Config\ConfigReaderInterface as AligentSitemapConfigReaderInterface;
use Magento\Sitemap\Model\ResourceModel\Catalog\Product;
use Magento\Catalog\Model\Product\Visibility;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
@@ -35,7 +35,7 @@ class GetValidProductPagesForSitemap
/**
* Product constructor.
*
- * @param AligentSitemapConfig $aligentSitemapConfig
+ * @param AligentSitemapConfigReaderInterface $aligentSitemapConfig
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
* @param ProductResource $productResource
@@ -47,7 +47,7 @@ class GetValidProductPagesForSitemap
* @param ReadHandler $mediaGalleryReadHandler
*/
public function __construct(
- private readonly AligentSitemapConfig $aligentSitemapConfig,
+ private readonly AligentSitemapConfigReaderInterface $aligentSitemapConfig,
private readonly ScopeConfigInterface $scopeConfig,
private readonly StoreManagerInterface $storeManager,
private readonly ProductResource $productResource,
diff --git a/Plugin/Model/ResourceModel/Cms/Page/GetValidCmsPagesForSitemap.php b/Plugin/Model/ResourceModel/Cms/Page/GetValidCmsPagesForSitemap.php
index c4de636..cd21cbc 100644
--- a/Plugin/Model/ResourceModel/Cms/Page/GetValidCmsPagesForSitemap.php
+++ b/Plugin/Model/ResourceModel/Cms/Page/GetValidCmsPagesForSitemap.php
@@ -12,7 +12,7 @@
use Magento\Cms\Api\GetUtilityPageIdentifiersInterface;
use Magento\Framework\Exception\LocalizedException;
use Zend_Db_Statement_Exception;
-use Aligent\Sitemap\Model\Config\Data as AligentSitemapConfig;
+use Aligent\Sitemap\Model\Config\ConfigReaderInterface as AligentSitemapConfigReaderInterface;
use Magento\Sitemap\Model\ResourceModel\Cms\Page;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\DataObject;
@@ -22,13 +22,13 @@ class GetValidCmsPagesForSitemap
/**
* @param GetUtilityPageIdentifiersInterface $getUtilityPageIdentifiers
* @param MetadataPool $metadataPool
- * @param AligentSitemapConfig $aligentSitemapConfig
+ * @param AligentSitemapConfigReaderInterface $aligentSitemapConfig
* @param Page $page
*/
public function __construct(
private readonly GetUtilityPageIdentifiersInterface $getUtilityPageIdentifiers,
private readonly MetadataPool $metadataPool,
- private readonly AligentSitemapConfig $aligentSitemapConfig,
+ private readonly AligentSitemapConfigReaderInterface $aligentSitemapConfig,
private readonly Page $page
) {
}
diff --git a/Test/Unit/Model/ItemProvider/PwaUrlTest.php b/Test/Unit/Model/ItemProvider/PwaUrlTest.php
new file mode 100644
index 0000000..a50dc89
--- /dev/null
+++ b/Test/Unit/Model/ItemProvider/PwaUrlTest.php
@@ -0,0 +1,96 @@
+getConfigReaderMock();
+ $itemFactoryMock = $this->getItemFactoryMock();
+ $aligentSitemapConfigMock = $this->getAligentSitemapConfigMock();
+ $resolver = new PwaUrl($configReaderMock, $itemFactoryMock, $aligentSitemapConfigMock);
+ $items = $resolver->getItems(1);
+
+ $this->assertCount(2, $items);
+ foreach ($items as $item) {
+ $this->assertSame('daily', $item->getChangeFrequency());
+ $this->assertSame('1.0', $item->getPriority());
+ }
+ }
+
+ /**
+ * @return SitemapItemInterfaceFactory|MockObject
+ */
+ private function getItemFactoryMock(): SitemapItemInterfaceFactory|MockObject
+ {
+ $itemFactoryMock = $this->getMockBuilder(SitemapItemInterfaceFactory::class)
+ ->setMethods(['create'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $itemFactoryMock->expects($this->any())
+ ->method('create')
+ ->willReturnCallback(function ($data) {
+ $helper = new ObjectManager($this);
+
+ return $helper->getObject(SitemapItem::class, $data);
+ });
+
+ return $itemFactoryMock;
+ }
+
+ /**
+ * @return ConfigReaderInterface|MockObject
+ */
+ private function getConfigReaderMock(): MockObject|ConfigReaderInterface
+ {
+ $configReaderMock = $this->getMockForAbstractClass(ConfigReaderInterface::class);
+ $configReaderMock->expects($this->any())
+ ->method('getPriority')
+ ->willReturn('1.0');
+ $configReaderMock->expects($this->any())
+ ->method('getChangeFrequency')
+ ->willReturn('daily');
+
+ return $configReaderMock;
+ }
+
+ /**
+ * @return AligentSitemapConfigReaderInterface|MockObject
+ */
+ private function getAligentSitemapConfigMock(): MockObject|AligentSitemapConfigReaderInterface
+ {
+ $aligentSitemapConfigMock = $this->getMockForAbstractClass(
+ AligentSitemapConfigReaderInterface::class
+ );
+ $aligentSitemapConfigMock->expects($this->any())
+ ->method('isPwaPagesInclude')
+ ->with(1)
+ ->willReturn(true);
+ $aligentSitemapConfigMock->expects($this->any())
+ ->method('getPwaPagesUrlKey')
+ ->with(1)
+ ->willReturn(['test-url-key','test-url-key-2']);
+
+ return $aligentSitemapConfigMock;
+ }
+}
diff --git a/etc/di.xml b/etc/di.xml
index 6f7d792..a684b1d 100644
--- a/etc/di.xml
+++ b/etc/di.xml
@@ -19,6 +19,9 @@
+
+