Skip to content

Commit

Permalink
orders with the agreement only are now send to heureka
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek-rostislav committed Apr 17, 2024
1 parent a1583fa commit 884fa4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 2 additions & 1 deletion packages/framework/src/Model/Order/OrderFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public function sendHeurekaOrderInfo(int $orderId): bool
$domainConfig = $this->domain->getDomainConfigById($order->getDomainId());
$locale = $domainConfig->getLocale();

if ($this->heurekaFacade->isDomainLocaleSupported($locale) === false ||
if ($order->isHeurekaAgreement() === false ||
$this->heurekaFacade->isDomainLocaleSupported($locale) === false ||
$this->heurekaFacade->isHeurekaShopCertificationActivated($order->getDomainId()) === false
) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ public function testNotSendHeurekaOrderInfoWhenDomainLocaleNotSupported(): void
$this->runHeurekaTest($heurekaFacade);
}

public function testNotSendHeurekaOrderInfoForOrderWithoutAgreement(): void
{
$heurekaFacade = $this->createMock(HeurekaFacade::class);
$heurekaFacade->method('isHeurekaShopCertificationActivated')->willReturn(true);
$heurekaFacade->method('isDomainLocaleSupported')->willReturn(true);

$heurekaFacade->expects($this->never())->method('sendOrderInfo');

$this->runHeurekaTest($heurekaFacade, false);
}

public function testSendHeurekaOrderInfo(): void
{
$heurekaFacade = $this->createMock(HeurekaFacade::class);
Expand Down Expand Up @@ -123,10 +134,11 @@ private function createOrderFacade(HeurekaFacade $heurekaFacade, Order $order):

/**
* @param \Shopsys\FrameworkBundle\Model\Heureka\HeurekaFacade $heurekaFacade
* @param bool $heurekaAgreement
*/
private function runHeurekaTest(HeurekaFacade $heurekaFacade): void
private function runHeurekaTest(HeurekaFacade $heurekaFacade, bool $heurekaAgreement = true): void
{
$order = $this->createOrderMock();
$order = $this->createOrderMock($heurekaAgreement);
$orderFacade = $this->createOrderFacade($heurekaFacade, $order);
$orderFacade->sendHeurekaOrderInfo($order->getId());
}
Expand All @@ -143,13 +155,15 @@ private function createDomain(): Domain
}

/**
* @param bool $heurekaAgreement
* @return \PHPUnit\Framework\MockObject\MockObject|\Shopsys\FrameworkBundle\Model\Order\Order
*/
private function createOrderMock(): MockObject
private function createOrderMock(bool $heurekaAgreement): MockObject
{
$order = $this->createMock(Order::class);
$order->method('getId')->willReturn(1);
$order->method('getDomainId')->willReturn(Domain::FIRST_DOMAIN_ID);
$order->method('isHeurekaAgreement')->willReturn($heurekaAgreement);

return $order;
}
Expand Down

0 comments on commit 884fa4a

Please sign in to comment.