Skip to content

Commit 5895158

Browse files
Stanislav Idolovrostyslav-hymon
authored andcommitted
ENGCOM-1050: Moved Google Analytics block code to head tag #8837 #14293
(cherry picked from commit 152ae09)
1 parent 733fb43 commit 5895158

File tree

2 files changed

+10
-8
lines changed
  • app/code/Magento/GoogleAnalytics/etc/adminhtml
  • dev/tests/integration/testsuite/Magento/GoogleAnalytics/Block

2 files changed

+10
-8
lines changed

app/code/Magento/GoogleAnalytics/etc/adminhtml/system.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
<field id="*/*/active">1</field>
2424
</depends>
2525
</field>
26-
27-
<field id="anonymize" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
26+
<field id="anonymize" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
2827
<label>Anonymize IP</label>
2928
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
30-
<depends>
29+
<depends>
3130
<field id="*/*/active">1</field>
3231
</depends>
3332
</field>

dev/tests/integration/testsuite/Magento/GoogleAnalytics/Block/GaTest.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\GoogleAnalytics\Block;
88

9-
use Magento\Framework\App\ObjectManager;
109
use Magento\TestFramework\TestCase\AbstractController;
1110

1211
class GaTest extends AbstractController
@@ -25,9 +24,7 @@ protected function setUp()
2524
{
2625
parent::setUp();
2726
$this->dispatch('/');
28-
$this->layout = ObjectManager::getInstance()->get(
29-
\Magento\Framework\View\LayoutInterface::class
30-
);
27+
$this->layout = $this->_objectManager->get(\Magento\Framework\View\LayoutInterface::class);
3128
}
3229

3330
/**
@@ -90,6 +87,12 @@ public function testBlockOutputExistsWhenGaIsEnabled()
9087
*/
9188
private function getGaBlockFromNode($nodeName = 'head.additional')
9289
{
93-
return $this->layout->getChildBlock($nodeName, 'google_analytics');
90+
$childBlocks = $this->layout->getChildBlocks($nodeName);
91+
foreach ($childBlocks as $block) {
92+
if (strpos($block->getNameInLayout(), 'google_analytics') !== false) {
93+
return $block;
94+
}
95+
}
96+
return false;
9497
}
9598
}

0 commit comments

Comments
 (0)