Skip to content

Commit

Permalink
[ECP-9482] Put magentoDetails method in data class
Browse files Browse the repository at this point in the history
  • Loading branch information
sushmita committed Oct 8, 2024
1 parent dc1b659 commit 06aa3c6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
11 changes: 1 addition & 10 deletions Gateway/Request/Header/ExternalPlatformHeaderDataBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,9 @@ public function build(array $buildSubject): array
return ['headers' => $headers];
}

public function getMagentoDetails(): array
{
return [
'name' => $this->productMetadata->getName(),
'version' => $this->productMetadata->getVersion(),
'edition' => $this->productMetadata->getEdition(),
];
}

public function buildRequestHeaders($payment = null): array
{
$magentoDetails = $this->getMagentoDetails();
$magentoDetails = $this->adyenHelper->getMagentoDetails();
$headers = [
ExternalPlatformHeaderDataBuilderInterface::EXTERNAL_PLATFORM_NAME => $magentoDetails['name'],
ExternalPlatformHeaderDataBuilderInterface::EXTERNAL_PLATFORM_VERSION => $magentoDetails['version'],
Expand Down
9 changes: 9 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,15 @@ public function initializeAdyenClient(
return $client;
}

public function getMagentoDetails(): array
{
return [
'name' => $this->productMetadata->getName(),
'version' => $this->productMetadata->getVersion(),
'edition' => $this->productMetadata->getEdition(),
];
}

public function buildApplicationInfo(Client $client) :ApplicationInfo
{
$applicationInfo = new ApplicationInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Adyen\Payment\Test\Unit\Gateway\Request;

use Adyen\Payment\Gateway\Request\Header\ExternalPlatformHeaderDataBuilder;
use Adyen\Payment\Gateway\Request\HeaderDataBuilder;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use Adyen\Payment\Helper\Data;
Expand All @@ -14,7 +15,7 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class HeaderDataBuilderTest extends AbstractAdyenTestCase
class ExternalPlatformHeaderDataBuilderTest extends AbstractAdyenTestCase
{
/**
* @var HeaderDataBuilder
Expand All @@ -35,7 +36,7 @@ protected function setUp(): void
->getMock();

$this->headerDataBuilder = $objectManager->getObject(
HeaderDataBuilder::class,
ExternalPlatformHeaderDataBuilder::class,
[
'adyenHelper' => $this->adyenHelperMock
]
Expand Down

0 comments on commit 06aa3c6

Please sign in to comment.