Skip to content

Commit 2917c63

Browse files
committed
AC-15461:Migration New Relic from REST v2 to NerdGraph (GraphQL)
1 parent bdd18d5 commit 2917c63

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

app/code/Magento/NewRelicReporting/Test/Unit/ViewModel/BrowserMonitoringFooterJsTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
use PHPUnit\Framework\MockObject\MockObject;
1414
use PHPUnit\Framework\TestCase;
1515

16+
/**
17+
* Test for BrowserMonitoringFooterJs ViewModel
18+
*
19+
* @covers \Magento\NewRelicReporting\ViewModel\BrowserMonitoringFooterJs
20+
*/
1621
class BrowserMonitoringFooterJsTest extends TestCase
1722
{
1823
/**
@@ -47,8 +52,8 @@ public static function getContentDataProvider(): array
4752
{
4853
return [
4954
'enabled_with_content' => [true,
50-
'<script>/* NewRelic Footer code */</script>',
51-
'<script>/* NewRelic Footer code */</script>'
55+
'<script type="text/x-magento-init">{"*":{"newRelicFooter":{"enabled":true}}}</script>',
56+
'<script type="text/x-magento-init">{"*":{"newRelicFooter":{"enabled":true}}}</script>'
5257
],
5358
'enabled_with_null' => [true, null, null],
5459
'enabled_with_empty' => [true, '', ''],
@@ -70,7 +75,8 @@ public function testGetContent(bool $isEnabled, ?string $footerContent, ?string
7075
$this->newRelicWrapperMock->method('isAutoInstrumentEnabled')->willReturn($isEnabled);
7176

7277
if ($isEnabled) {
73-
$this->newRelicWrapperMock->method('getBrowserTimingFooter')->with(false)->willReturn($footerContent);
78+
$this->newRelicWrapperMock->method('getBrowserTimingFooter')
79+
->with(false)->willReturn($footerContent);
7480
}
7581

7682
$this->assertEquals($expected, $this->viewModel->getContent());
@@ -90,7 +96,7 @@ public function testGetContentCallsBrowserTimingFooterWithCorrectParameter(): vo
9096
$this->newRelicWrapperMock->expects($this->once())
9197
->method('getBrowserTimingFooter')
9298
->with($this->identicalTo(false))
93-
->willReturn('<script>test</script>');
99+
->willReturn('<script type="text/x-magento-init">{"*":{"newRelicFooter":{"enabled":true}}}</script>');
94100

95101
$this->viewModel->getContent();
96102
}

app/code/Magento/NewRelicReporting/Test/Unit/ViewModel/BrowserMonitoringHeaderJsTest.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
use PHPUnit\Framework\MockObject\MockObject;
1414
use PHPUnit\Framework\TestCase;
1515

16+
/**
17+
* Test for BrowserMonitoringHeaderJs ViewModel
18+
*
19+
* @covers \Magento\NewRelicReporting\ViewModel\BrowserMonitoringHeaderJs
20+
*/
1621
class BrowserMonitoringHeaderJsTest extends TestCase
1722
{
1823
/**
@@ -47,8 +52,8 @@ public static function getContentDataProvider(): array
4752
{
4853
return [
4954
'enabled_with_content' => [true,
50-
'<script>/* NewRelic Header code */</script>',
51-
'<script>/* NewRelic Header code */</script>'
55+
'<script type="text/x-magento-init">{"*":{"newRelicHeader":{"enabled":true}}}</script>',
56+
'<script type="text/x-magento-init">{"*":{"newRelicHeader":{"enabled":true}}}</script>'
5257
],
5358
'enabled_with_null' => [true, null, null],
5459
'enabled_with_empty' => [true, '', ''],
@@ -70,7 +75,8 @@ public function testGetContent(bool $isEnabled, ?string $headerContent, ?string
7075
$this->newRelicWrapperMock->method('isAutoInstrumentEnabled')->willReturn($isEnabled);
7176

7277
if ($isEnabled) {
73-
$this->newRelicWrapperMock->method('getBrowserTimingHeader')->with(false)->willReturn($headerContent);
78+
$this->newRelicWrapperMock->method('getBrowserTimingHeader')
79+
->with(false)->willReturn($headerContent);
7480
}
7581

7682
$this->assertEquals($expected, $this->viewModel->getContent());
@@ -90,7 +96,7 @@ public function testGetContentCallsBrowserTimingHeaderWithCorrectParameter(): vo
9096
$this->newRelicWrapperMock->expects($this->once())
9197
->method('getBrowserTimingHeader')
9298
->with($this->identicalTo(false))
93-
->willReturn('<script>test</script>');
99+
->willReturn('<script type="text/x-magento-init">{"*":{"newRelicHeader":{"enabled":true}}}</script>');
94100

95101
$this->viewModel->getContent();
96102
}

0 commit comments

Comments
 (0)