Skip to content

Commit 6792769

Browse files
authored
issue-resolution/plugin-version (#189)
* fixed issue with the plugin version in browser events * updated unit tests * fixed static test issues
1 parent fea21c3 commit 6792769

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

app/code/Meta/BusinessExtension/Helper/FBEHelper.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
use Magento\Framework\App\ProductMetadata as FrameworkProductMetaData;
2828
use Magento\Framework\App\ResourceConnection;
2929
use Magento\Framework\HTTP\Client\Curl;
30-
use Magento\Framework\Module\ModuleListInterface;
3130
use Magento\Framework\ObjectManagerInterface;
3231
use Magento\Framework\UrlInterface;
3332
use Meta\BusinessExtension\Model\System\Config as SystemConfig;
@@ -75,11 +74,6 @@ class FBEHelper extends AbstractHelper
7574
*/
7675
private $resourceConnection;
7776

78-
/**
79-
* @var ModuleListInterface
80-
*/
81-
private $moduleList;
82-
8377
/**
8478
* @var SystemConfig
8579
*/
@@ -99,7 +93,6 @@ class FBEHelper extends AbstractHelper
9993
* @param StoreManagerInterface $storeManager
10094
* @param Curl $curl
10195
* @param ResourceConnection $resourceConnection
102-
* @param ModuleListInterface $moduleList
10396
* @param SystemConfig $systemConfig
10497
* @param ProductMetadataInterface $productMetadata
10598
*/
@@ -110,7 +103,6 @@ public function __construct(
110103
StoreManagerInterface $storeManager,
111104
Curl $curl,
112105
ResourceConnection $resourceConnection,
113-
ModuleListInterface $moduleList,
114106
SystemConfig $systemConfig,
115107
ProductMetadataInterface $productMetadata
116108
) {
@@ -120,7 +112,6 @@ public function __construct(
120112
$this->logger = $logger;
121113
$this->curl = $curl;
122114
$this->resourceConnection = $resourceConnection;
123-
$this->moduleList = $moduleList;
124115
$this->systemConfig = $systemConfig;
125116
$this->productMetadata = $productMetadata;
126117
}
@@ -142,7 +133,7 @@ public function getMagentoVersion(): string
142133
*/
143134
public function getPluginVersion()
144135
{
145-
return $this->moduleList->getOne(self::MODULE_NAME)['setup_version'];
136+
return $this->systemConfig->getModuleVersion();
146137
}
147138

148139
/**
@@ -152,7 +143,8 @@ public function getPluginVersion()
152143
*/
153144
public function getSource(): string
154145
{
155-
return $this->productMetadata->getEdition() == FrameworkProductMetaData::EDITION_NAME ? 'magento_opensource' : 'adobe_commerce';
146+
return $this->productMetadata->getEdition() == FrameworkProductMetaData::EDITION_NAME
147+
? 'magento_opensource' : 'adobe_commerce';
156148
}
157149

158150
/**
@@ -448,7 +440,6 @@ public function deleteConfigKeys($storeId)
448440
return $this;
449441
}
450442

451-
452443
/**
453444
* Is updated version
454445
*

app/code/Meta/BusinessExtension/Test/Unit/Helper/FBEHelperTest.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Magento\Framework\App\ProductMetadataInterface;
2424
use Magento\Framework\App\ResourceConnection;
2525
use Magento\Framework\HTTP\Client\Curl;
26-
use Magento\Framework\Module\ModuleListInterface;
2726
use Magento\Framework\ObjectManagerInterface;
2827
use Magento\Store\Model\StoreManagerInterface;
2928
use Meta\BusinessExtension\Model\System\Config;
@@ -43,9 +42,9 @@ class FBEHelperTest extends TestCase
4342
private $objectManagerInterface;
4443

4544
/**
46-
* @var MockObject
45+
* @var Config
4746
*/
48-
private $moduleList;
47+
private $systemConfig;
4948

5049
/**
5150
* @var ProductMetadataInterface|MockObject
@@ -74,8 +73,7 @@ public function setUp(): void
7473
$storeManager = $this->createMock(StoreManagerInterface::class);
7574
$curl = $this->createMock(Curl::class);
7675
$resourceConnection = $this->createMock(ResourceConnection::class);
77-
$this->moduleList = $this->createMock(ModuleListInterface::class);
78-
$systemConfig = $this->createMock(Config::class);
76+
$this->systemConfig = $this->createMock(Config::class);
7977
$this->productMetaData = $this->createMock(ProductMetadataInterface::class);
8078
$this->fbeHelper = new FBEHelper(
8179
$context,
@@ -84,8 +82,7 @@ public function setUp(): void
8482
$storeManager,
8583
$curl,
8684
$resourceConnection,
87-
$this->moduleList,
88-
$systemConfig,
85+
$this->systemConfig,
8986
$this->productMetaData
9087
);
9188
}
@@ -99,18 +96,14 @@ public function testCorrectPartnerAgent()
9996
{
10097
$magentoVersion = '2.3.5';
10198
$pluginVersion = '1.0.0';
102-
$this->moduleList->method('getOne')->willReturn(
103-
[
104-
'setup_version' => $pluginVersion
105-
]
106-
);
10799
$source = $this->fbeHelper->getSource();
108100
$productMetadata = $this->getMockBuilder(ProductMetadataInterface::class)
109101
->disableOriginalConstructor()
110102
->setMethods(['getVersion', 'getEdition', 'getName'])
111103
->getMock();
112104
$this->productMetaData->expects($this->once())->method('getVersion')->willReturn($magentoVersion);
113105
$this->objectManagerInterface->method('get')->willReturn($productMetadata);
106+
$this->systemConfig->method('getModuleVersion')->willReturn($pluginVersion);
114107
$this->assertEquals(
115108
sprintf('%s-%s-%s', $source, $magentoVersion, $pluginVersion),
116109
$this->fbeHelper->getPartnerAgent(true)

0 commit comments

Comments
 (0)